51Testing软件测试论坛

标题: Loadrunner 脚本中如何使用连接数据库,判断事务的成功和失败 [打印本页]

作者: meibaocai    时间: 2011-3-1 09:13
标题: Loadrunner 脚本中如何使用连接数据库,判断事务的成功和失败
1、如执行一个事务
lr_start_transaction("T_Egressive_brief_summary");
web_custom_request("springUser.saveResult.dwr",
.....
                "c0-e1=string:{p_callid}\n"
.....

lr_end_transaction("T_Egressive_brief_summary", LR_AUTO);
2、在执行web_custom_request需要连接oracle数据库,检查 call_list表中的status_fk字段,如果status_fk=2,则事务成功,否则失败。select count (*)from call_list t where t.id=p_callid ,这个p_callid 从事务中取

3、请各位大侠帮忙
作者: meibaocai    时间: 2011-3-1 09:14
在线等
作者: msnshow    时间: 2011-3-2 21:20
没有必要这么麻烦吧,是否成功有相应的提示信息的
作者: meibaocai    时间: 2011-3-3 09:10

作者: meibaocai    时间: 2011-3-3 09:16
返回消息中增加了,如下检查点,但是事务的成功数,和数据库表更新数不一致。所以想增加个数据库检查点,判断事务的成功与否。
web_reg_find("Fail=NotFound",
  "Search=Headers",
  "Text=200 OK",
  LAST);
作者: msnshow    时间: 2011-3-3 13:16
回复 5# meibaocai


    这样的话,可以把返回消息中增加上一段,从数据库中查询的结果,然后用关联取到这段值与提交的值对比看是否一致
作者: fankie    时间: 2011-3-3 14:33
楼主问题解决了吗?我也很想学习一下这个该怎么写。
作者: oldsuper    时间: 2011-3-3 22:33
如果是oracle的数据库
可以选择ora-2tier那个协议,用sqlplus登录数据库并查询的操作,然后把脚本粘过来,做一下参数化就可以了
作者: meibaocai    时间: 2011-3-7 10:46
还没有解决呢,oldsuper  能给个事例吗?
作者: meibaocai    时间: 2011-3-9 15:47
已经解决
作者: meibaocai    时间: 2011-3-9 15:47
如下:
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);

                }
作者: 594838545qq    时间: 2011-10-28 15:53
顶一个




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