|
本帖最后由 hankliu520 于 2011-12-23 11:51 编辑
在用双协议进行一些操作时碰到一些问题,在使用lr_db_getvalue获取数据库中列值时会有截断现象。暂时不知道到底什么原因,谷歌了好久没找到答案,求助。下面截取其中操作数据库的一段代码
loadrunner代码如下:lr_db_connect("StepName=DatabaseConnection",
"ConnectionString=Data Source=*****;Initial Catalog=*****ersist Security Info=True;User ID=****assword=****",
"ConnectionName=DatabaseConnection",
"ConnectionType=SQL",
LAST );
lr_db_executeSQLStatement("StepName=PerformQuery",
"ConnectionName=DatabaseConnection",
"SQLStatement=select HotelAddress,HotelName from *****",
"DatasetName=MyDataset",
LAST);
lr_db_getvalue("StepName=GetValue",
"DatasetName=MyDataset",
"Column=HotelAddress",
"Row=next",
"OutParam=HotelAddress1",
LAST);
lr_db_getvalue("StepName=GetValue",
"DatasetName=MyDataset",
"Column=HotelName",
"Row=next",
"OutParam=HotelName1",
LAST);
lr_output_message("The HotelAddress is: %s", lr_eval_string("{HotelAddress1}") );
lr_output_message("The HotelName is: %s", lr_eval_string("{HotelName1}") );
loadrunner输出结果如下:
Starting action Action.Action.c(20): DB Connection "DatabaseConnection" started ... Wait ....
Action.c(144): SQL Statement execution "erformQuery" startedAction.c(144): ================================================
Action.c(150): Get db value "GetValue" started
Action.c(150): Notify: Saving Parameter "HotelAddress1 = 长春市朝阳区芍药居16号楼(靠近"
Action.c(150): ================================================
Action.c(156): Get db value "GetValue" started
Action.c(156): Notify: Saving Parameter "HotelName1 = 长春延\xb0"
Action.c(156): ================================================
Action.c(162): Notify: Parameter Substitution: parameter "HotelAddress1" = "长春市朝阳区芍药居16号楼(靠近"Action.c(162): The HotelAddress is: 长春市朝阳区芍药居16号楼(靠近
Action.c(163): Notify: Parameter Substitution: parameter "HotelName1" = "长春延"
Action.c(163): The HotelName is: 长春延
Ending action Action.
数据库中的数据如下:
表设计如下:
可以看到保存参数时就已经进行了截断处理了。
后面的打印输出就直接出来了。
进行了如下实验:
插入了一条纯数字数据长度为40位.
结果正常.
Action.c(18): ================================
Action.c(18): 1 012345678901234567890...
Action.c(18): ********End printing ***********
Action.c(18):
Action.c(29): Get db value "GetValue" started
Action.c(29): Notify: Saving Parameter "HotelName1 = 0123456789012345678901234567890123456789"
Action.c(29): ================================================
Action.c(36): Notify: Parameter Substitution: parameter "HotelName1" = "0123456789012345678901234567890123456789"
对刚才的hotelname进行了单独实验,打印输入如下:
Starting action Action.
Action.c(5): DB Connection "DatabaseConnection" started ... Wait ....
Action.c(13): SQL Statement execution "erformQuery" started
Action.c(13): ================================================
Action.c(18): Dataset action "rintDataset" started
Action.c(18):
Action.c(18): ******** Start printing ***********
Action.c(18): Number of records in dataset = 1
Action.c(18): Num. HotelName
Action.c(18): ================================
Action.c(18): 1 长春延安西路店
Action.c(18): ********End printing ***********
Action.c(18):
Action.c(29): Get db value "GetValue" started
Action.c(29): Notify: Saving Parameter "HotelName1 = 长春延\xb0"
Action.c(29): ================================================
Action.c(36): Notify: Parameter Substitution: parameter "HotelName1" = "长春延"
Action.c(36): The HotelName is: 长春延
Action.c(38): Dataset action "rintDataset" started
Ending action Action.
通过以上暂时可以看出来,是函数lr_db_getvalue对中文获取支持不好,会截断,函数lr_db_dataset_action 打印时中文可以全部打印出来。
不知道这个结论是否正确。 |
|