51Testing软件测试论坛

标题: loadrunner 连接oracle数据库判断事务的成功失败, [打印本页]

作者: meibaocai    时间: 2011-3-8 10:33
标题: loadrunner 连接oracle数据库判断事务的成功失败,
lrd_ora8_stmt(OraStm1, "select count(*) from call_list t where t.status_fk='2'and t.id=" "'2011022100000501'\n", 1, 0, 0);
        lrd_ora8_attr_set(OraStm1, PREFETCH_ROWS, "0", -1, 0);
        lrd_ora8_attr_set(OraStm1, PREFETCH_MEMORY, "0", -1, 0);
        lrd_ora8_exec(OraSvc1, OraStm1, 0, 0, &uliRowsProcessed, 0, 0, 0, 0,
        0);
        lrd_ora8_bind_col(OraStm1, &OraDef1, 1, &NUM, 0, 0);
    //lrd_ora8_save_col (OraStm1, 1, 1, 0, "ROW");
    lrd_ora8_fetch(OraStm1, -1, 100, &uliFetchedRows, PrintRow12, 2, 0, 0);
错误:Action.c (44): type error in argument 6 to `lrdfnc_ora8_fetch'; found `unsigned long' expected `pointer to int function(const pointer to void,const unsigned long)'
d:\\program files\\mercury\\loadrunner\\scripts\\blue\\\\combined_blue.c (6): 1 errors, not writing pre_cci.ci
作者: meibaocai    时间: 2011-3-8 10:34
如果把:    lrd_ora8_fetch(OraStm1, -1, 100, &uliFetchedRows, PrintRow12, 2, 0, 0);
修改为    lrd_ora8_fetch(OraStm1, -1, 100, &uliFetchedRows, 0, 2, 0, 0);
报以下错误:Action.c(37): lrd_ora8_stmt: ERROR, return-code=LRDE2090
请各位大侠帮忙看看啊
作者: meibaocai    时间: 2011-3-8 10:34
脚本如下:
#include<lrd.h>
static LRD_INIT_INFO InitInfo={LRD_INIT_INFO_EYECAT};
static LRD_DEFAULT_DB_VERSION DBTypeVersion[]={{LRD_DBTYPE_NONE,LRD_DBVERSION_NONE}};
static LRD_VAR_DESC NUM ={LRD_VAR_DESC_EYECAT, 15, 23, LRD_DBTYPE_ORACLE, {1, 1, 0},DT_NUMERIC};

static void FAR * OraEnv1;
static void FAR * OraSvc1;
static void FAR * OraSrv1;
static void FAR * OraSes1;
static void FAR * OraStm1;
static void FAR * OraDef1;
vuser_init()
{
        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);
       
        //设置数据库名称,我的是oracle,odbc中连接数据库名称就是这个
        lrd_server_attach(OraSrv1, "190TP_172.17.225.190", 20, 0, 0);
        lrd_ora8_attr_set_from_handle(OraSvc1,SERVER,OraSrv1,0,0);
       
        //用户名和密码
        lrd_ora8_attr_set(OraSes1,USERNAME,"TP1",-1,0);
        lrd_ora8_attr_set(OraSes1,PASSWORD,"TP1",-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);
        return 0;
}
作者: meibaocai    时间: 2011-3-8 10:35
Action()
{
    unsigned long rownum;
        unsigned long uliFetchedRows;
        unsigned long uliRowsProcessed;
        unsigned long PrintRow12;
        static void FAR * OraStm1;
unsigned long  ROW;

lrd_ora8_stmt(OraStm1, "select count(*) from call_list t where t.status_fk='2'and t.id=" "'2011022100000501'\n", 1, 0, 0);
        lrd_ora8_attr_set(OraStm1, PREFETCH_ROWS, "0", -1, 0);
        lrd_ora8_attr_set(OraStm1, PREFETCH_MEMORY, "0", -1, 0);
        lrd_ora8_exec(OraSvc1, OraStm1, 0, 0, &uliRowsProcessed, 0, 0, 0, 0,
        0);
        lrd_ora8_bind_col(OraStm1, &OraDef1, 1, &NUM, 0, 0);
    //lrd_ora8_save_col (OraStm1, 1, 1, 0, "ROW");
    lrd_ora8_fetch(OraStm1, -1, 100, &uliFetchedRows, 0, 2, 0, 0);

        lr_end_transaction("T_Egressive_brief_summary", LR_AUTO);

        return 0;                                                                                       
}
作者: meibaocai    时间: 2011-3-8 10:35
vuser_end()
{
        lrd_session_end(OraSvc1, OraSes1, 0, 0);
        lrd_server_detach(OraSrv1, 0, 0);
        lrd_handle_free(&OraEnv1, 0);
        return 0;
}
作者: meibaocai    时间: 2011-3-9 09:33
大侠们帮帮看看,急。在线等
作者: meibaocai    时间: 2011-3-9 15:43
已解决,如下:
        #include "lrd.h"
        static LRD_INIT_INFO InitInfo={LRD_INIT_INFO_EYECAT};
        static LRD_DEFAULT_DB_VERSION DBTypeVersion[]={{LRD_DBTYPE_NONE,LRD_DBVERSION_NONE}};
        static LRD_VAR_DESC NUM ={LRD_VAR_DESC_EYECAT, 15, 23, LRD_DBTYPE_ORACLE, {1, 1, 0},DT_NUMERIC};
        static void FAR * OraEnv1;
        static void FAR * OraSvc1;
        static void FAR * OraSrv1;
        static void FAR * OraSes1;
        static void FAR * OraStm1;
        static void FAR * OraDef1;
        static unsigned long rownum;
        static unsigned long uliFetchedRows;
        static unsigned long uliRowsProcessed;
        char  ROW;

vuser_init()
{
       
        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);

        lr_think_time(5);

        //设置数据库名称,我的是oracle,odbc中连接数据库名称就是这个
        lrd_server_attach(OraSrv1, "190TP_172.17.225.190", -1, 0, 0);
        lrd_ora8_attr_set_from_handle(OraSvc1,SERVER,OraSrv1,0,0);
        lr_think_time(5);
       
        //用户名和密码
        lrd_ora8_attr_set(OraSes1,USERNAME,"TP1",-1,0);
        lrd_ora8_attr_set(OraSes1,PASSWORD,"TP1",-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);
        return 0;
}
作者: meibaocai    时间: 2011-3-9 15:43
LAST);*/
                lrd_ora8_stmt(OraStm1, "select count(*) from call_list where status_fk='2'and id='{p_callid}'", 1,0,0);
                lrd_ora8_exec(OraSvc1, OraStm1, 0, 0,&rownum, 0, 0, 0, 0, 1);
                lrd_ora8_bind_col(OraStm1, &OraDef1, 1, &NUM, 0, 0);
                lrd_ora8_save_col (OraStm1, 1, 1, 0, "ROW");
                lrd_ora8_fetch(OraStm1, -1, 15, &uliFetchedRows, 0, 2, 0, 0);
                lr_output_message("value : %s",  lr_eval_string("The  count is: {ROW}"));        
       
                if(atoi(lr_eval_string("{ROW}"))>0)
                {
                        lr_end_transaction("T_Egressive_brief_summary", LR_PASS);

                }
                else
                {
                        lr_end_transaction("T_Egressive_brief_summary", LR_FAIL);

                }
作者: meibaocai    时间: 2011-3-9 15:43
vuser_end()
{       
         lrd_handle_free(&OraStm1, 0);
       
         lrd_session_end(OraSvc1, OraSes1, 0, 0);
       
         lrd_server_detach(OraSrv1, 0, 0);
       
         lrd_handle_free(&OraEnv1, 0);
        return 0;
       
}
作者: vickiren    时间: 2011-9-14 14:18
好东西呀




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