loadrunner连接数据库oracle脚本 博客分类: 02-loadrunner脚本部分经验总结 IT性能
程序员文章站
2024-02-06 11:43:28
...
//初始化并连接数据库部分
lrd_init(&InitInfo, DBTypeVersion);
lrd_initialize_db(LRD_DBTYPE_ORACLE, 3, 0);
lrd_env_init(LRD_DBTYPE_ORACLE, &OraEnv1, 0, 0);
lrd_ora8_handle_alloc(OraEnv1, SVCCTX, &OraSvc1, 0);
lrd_ora8_handle_alloc(OraEnv1, SERVER, &OraSrv1, 0);
lrd_ora8_handle_alloc(OraEnv1, SESSION, &OraSes1, 0);
lrd_server_attach(OraSrv1, "HKCTS01_10.10.4.107", -1, 0, 0);
lrd_ora8_attr_set_from_handle(OraSvc1, SERVER, OraSrv1, 0, 0);
lrd_ora8_attr_set_from_handle(OraSvc1, SESSION, OraSes1, 0, 0);
lrd_ora8_attr_set(OraSes1, USERNAME, "atii", -1, 0);
lrd_ora8_attr_set(OraSes1, PASSWORD, lr_decrypt("atii"), -1, 0);
lrd_session_begin(OraSvc1, OraSes1, 1, 0, 0);
lrd_ora8_handle_alloc(OraEnv1, STMT, &OraStm2, 0);
lrd_ora8_stmt(OraStm2, "delete from t_at_flight\n", 1, 0, 0);
//insert into rec_system values (seq_rec_system.nextval,'0.0.0.0','测试','测试','a',sysdate,'测试')
lrd_ora8_attr_set(OraStm2, PREFETCH_ROWS, "0", -1, 0);
lrd_ora8_attr_set(OraStm2, PREFETCH_MEMORY, "0", -1, 0);
lrd_ora8_exec(OraSvc1, OraStm2, 1, 0, &uliRowsProcessed, 0, 0, 0, 0, 0);
lrd_handle_free(&OraStm2, 0);
//数据库结束释放资源
lrd_session_end(OraSvc1, OraSes1, 0, 0);
lrd_server_detach(OraSrv1, 0, 0);
lrd_handle_free(&OraSrv1, 0);
lrd_handle_free(&OraSvc1, 0);
lrd_handle_free(&OraSes1, 0);
lrd_handle_free(&OraEnv1, 0);
lrd_init(&InitInfo, DBTypeVersion);
lrd_initialize_db(LRD_DBTYPE_ORACLE, 3, 0);
lrd_env_init(LRD_DBTYPE_ORACLE, &OraEnv1, 0, 0);
lrd_ora8_handle_alloc(OraEnv1, SVCCTX, &OraSvc1, 0);
lrd_ora8_handle_alloc(OraEnv1, SERVER, &OraSrv1, 0);
lrd_ora8_handle_alloc(OraEnv1, SESSION, &OraSes1, 0);
lrd_server_attach(OraSrv1, "HKCTS01_10.10.4.107", -1, 0, 0);
lrd_ora8_attr_set_from_handle(OraSvc1, SERVER, OraSrv1, 0, 0);
lrd_ora8_attr_set_from_handle(OraSvc1, SESSION, OraSes1, 0, 0);
lrd_ora8_attr_set(OraSes1, USERNAME, "atii", -1, 0);
lrd_ora8_attr_set(OraSes1, PASSWORD, lr_decrypt("atii"), -1, 0);
lrd_session_begin(OraSvc1, OraSes1, 1, 0, 0);
lrd_ora8_handle_alloc(OraEnv1, STMT, &OraStm2, 0);
lrd_ora8_stmt(OraStm2, "delete from t_at_flight\n", 1, 0, 0);
//insert into rec_system values (seq_rec_system.nextval,'0.0.0.0','测试','测试','a',sysdate,'测试')
lrd_ora8_attr_set(OraStm2, PREFETCH_ROWS, "0", -1, 0);
lrd_ora8_attr_set(OraStm2, PREFETCH_MEMORY, "0", -1, 0);
lrd_ora8_exec(OraSvc1, OraStm2, 1, 0, &uliRowsProcessed, 0, 0, 0, 0, 0);
lrd_handle_free(&OraStm2, 0);
//数据库结束释放资源
lrd_session_end(OraSvc1, OraSes1, 0, 0);
lrd_server_detach(OraSrv1, 0, 0);
lrd_handle_free(&OraSrv1, 0);
lrd_handle_free(&OraSvc1, 0);
lrd_handle_free(&OraSes1, 0);
lrd_handle_free(&OraEnv1, 0);