51Testing软件测试论坛

标题: LR的Oracle(2-tier)协议中如何做参数化? [打印本页]

作者: naoge    时间: 2011-1-11 09:14
标题: LR的Oracle(2-tier)协议中如何做参数化?
想压存储过程,录制下来都是这种信息,我怎样进行参数化呢?

lrd_init(&InitInfo, DBTypeVersion);
        lrd_initialize_db(LRD_DBTYPE_ORACLE, 2, 0);
        lrd_env_init(LRD_DBTYPE_ORACLE, &OraEnv1, 0, 0);
        lrd_ora8_handle_alloc(OraEnv1, SERVER, &OraSrv1, 0);
        lrd_ora8_handle_alloc(OraEnv1, SVCCTX, &OraSvc1, 0);
        lrd_ora8_handle_alloc(OraEnv1, SESSION, &OraSes1, 0);
        lrd_ora8_handle_alloc(OraEnv1, SESSION, &OraSes2, 0);
        lrd_server_attach(OraSrv1, "test111", 7, 0, 0);
        lrd_ora8_attr_set_from_handle(OraSvc1, SERVER, OraSrv1, 0, 0);
        lrd_ora8_attr_set(OraSes1, USERNAME, "portaluser", -1, 0);
        lrd_ora8_attr_set(OraSes1, PASSWORD, lr_decrypt("4cbfe1dbe3b5e07d"), -1, 0);
        lrd_ora8_attr_set_from_handle(OraSvc1, SESSION, OraSes1, 0, 0);
        lrd_session_begin(OraSvc1, OraSes1, 1, 0, 0);
        lrd_ora8_handle_alloc(OraEnv1, STMT, &OraStm1, 0);
        lrd_ora8_stmt(OraStm1, "SELECT USER FROM DUAL", 1, 32, 0);
        lrd_ora8_exec(OraSvc1, OraStm1, 0, 0, &uliRowsProcessed, 0, 0, 0, 0,
        0);
        lrd_ora8_bind_col(OraStm1, &OraDef1, 1, &USER_D1, 0, 0);
        lrd_ora8_fetch(OraStm1, -1, 1, &uliFetchedRows, PrintRow2, 2, 0, 0);
        GRID8(2);








        lrd_handle_free(&OraStm1, 0);
        lrd_ora8_handle_alloc(OraEnv1, STMT, &OraStm2, 0);
        lrd_ora8_stmt(OraStm2, "BEGIN DBMS_OUTPUT.DISABLE; END;", 1, 32, 0);
        lrd_ora8_exec(OraSvc1, OraStm2, 1, 0, &uliRowsProcessed, 0, 0, 0, 0,
        0);
        lrd_handle_free(&OraStm2, 0);
        lrd_ora8_handle_alloc(OraEnv1, STMT, &OraStm3, 0);
        lrd_ora8_stmt(OraStm3, "SELECT ATTRIBUTE,SCOPE,NUMERIC_VALUE,CHAR_VALUE,DATE_VALUE FROM "
        "SYSTEM.PRODUCT_PRIVS WHERE (UPPER('SQL*Plus') LIKE UPPER"
        "(PRODUCT)) AND (UPPER(USER) LIKE USERID)", 1, 32, 0);
        lrd_ora8_exec(OraSvc1, OraStm3, 0, 0, &uliRowsProcessed, 0, 0, 0, 0,
        0);
        lrd_ora8_bind_col(OraStm3, &OraDef2, 1, &ATTRIBUTE_D2, 0, 0);
        lrd_ora8_bind_col(OraStm3, &OraDef3, 2, &SCOPE_D3, 0, 0);
        lrd_ora8_bind_col(OraStm3, &OraDef4, 3, &NUMERIC_VALUE_D4, 0, 0);
        lrd_ora8_bind_col(OraStm3, &OraDef5, 4, &CHAR_VALUE_D5, 0, 0);
        lrd_ora8_bind_col(OraStm3, &OraDef6, 5, &DATE_VALUE_D6, 0, 0);
        lrd_ora8_fetch(OraStm3, -0, 1, &uliFetchedRows, 0, 2, 0, 0);
        lrd_handle_free(&OraStm3, 0);
        lrd_ora8_handle_alloc(OraEnv1, STMT, &OraStm4, 0);
        lrd_ora8_stmt(OraStm4, "SELECT CHAR_VALUE FROM SYSTEM.PRODUCT_PRIVS WHERE   (UPPER"
        "('SQL*Plus') LIKE UPPER(PRODUCT)) AND   ((UPPER(USER) LIKE "
        "USERID) OR (USERID = 'PUBLIC')) AND   (UPPER(ATTRIBUTE) = "
        "'ROLES')", 1, 32, 0);
        lrd_ora8_exec(OraSvc1, OraStm4, 0, 0, &uliRowsProcessed, 0, 0, 0, 0,
        0);
        lrd_ora8_bind_col(OraStm4, &OraDef7, 1, &CHAR_VALUE_D7, 0, 0);
        lrd_ora8_fetch(OraStm4, -0, 1, &uliFetchedRows, 0, 2, 0, 0);
        lrd_handle_free(&OraStm4, 0);
        lrd_ora8_handle_alloc(OraEnv1, STMT, &OraStm5, 0);
        lrd_ora8_stmt(OraStm5, "BEGIN DBMS_APPLICATION_INFO.SET_MODULE(:1,NULL); END;", 1, 32, 0);
        lrd_assign(&P1D8, "SQL*Plus", 0, 0, 0);
        lrd_ora8_bind_placeholder(OraStm5, &OraBnd1, "1", &P1D8,
        LRD_BIND_BY_POS, 0, 0);
        lrd_ora8_exec(OraSvc1, OraStm5, 1, 0, &uliRowsProcessed, 0, 0, 0, 0,
        0);
        GRID0(4);








        lrd_handle_free(&OraStm5, 0);
        lrd_ora8_handle_alloc(OraEnv1, STMT, &OraStm6, 0);
        lrd_ora8_stmt(OraStm6, "SELECT DECODE('A','A','1','2') FROM DUAL", 1, 32, 0);
        lrd_ora8_bind_col(OraStm6, &OraDef8, 1, &DECODE_A_A_1_2_D9, 0, 0);
        lrd_ora8_exec(OraSvc1, OraStm6, 1, 0, &uliRowsProcessed, 0, 0, 0, 0,
        0);
        lrd_ora8_print(OraStm6, PrintRow6);
        GRID0(6);








        lrd_handle_free(&OraStm6, 0);
        lrd_ora8_commit(OraSvc1, 0, 0);
        lrd_ora8_commit(OraSvc1, 0, 0);
        return 0;
作者: gztester    时间: 2011-1-11 10:20
参数化方式与WEB协议的类似
作者: naoge    时间: 2011-1-11 10:34
我没找到我要参数化的语句(web里参数都很明显,现在找不到),能指点下么?
作者: gztester    时间: 2011-1-11 11:10
你需要把脚本的每一句、每个函数都弄懂才行




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2