loadrunner Lr_类函数之lr_db_getValue()

来源:互联网 发布:网络配线架报价 编辑:程序博客网 时间:2024/06/04 19:49

lr_db_getValue()--常用函数

从数据集中检索值。
int lr_db_getValue(“StepName = <step_name>”,“DatasetName =<dataset_name>”,“Column = <column>”,“Row = <row>”,“OutParam =<output_parm>”,LAST);

参数说明:
StepName:步骤的名称,它出现在测试树中。可以使用任何文本。
DatasetName
:在lr_db_executeSQLStatement中指定的数据集的逻辑名称。
Column:从中检索值的数据集中的列的名称。
Row
:在获取数据之前将数据集光标设置为指定的行。之一:
  The row number(从1开始)
    current -
不移动光标
    next -
将光标设置到下一行
OutParam
:将包含该值的LoadRunner参数。
LAST
:此分隔符标记参数列表的结尾。

lr_db_getValue
函数从由lr_db_executeSQLStatement创建的数据集中检索值。
要点:此功能仅在Web服务脚本中可用。
当此函数到达数据集的最后一行时,该行未定义。如果在下次调用lr_db_getValue时指定Row = next,则脚本将继续运行到第一条记录,而不发出任何错误。
此功能不支持打印或输出二进制数据。从数据集检索的二进制值显示为<binary_data>

 

示例:lr_db_getValue
在以下示例中,lr_db_getValue检索由lr_db_executeSQLStatement创建的数据集中的三行的名称。名字保存在参数MyOutputParam中。
int i = 1;
lr_db_executeSQLStatement
(“StepName =PerformQuery”,
    
ConnectionName= db1”,
    
SQLStatement= SELECT dbo.Customer.CustIDdbo.Customer.FirstNamedbo.Customer.LastName FROM dbo.Customer”,
    
DatasetName =MyDataset”,
     LAST
;

while
i <4{
     lr_db_getvalue
(“StepName = GetValue”,
        
DatasetName = MyDataset”,
        
Column = FirstName”,
        
Row = next”,
        
OutParam = MyOutputParam”,
         LAST
;


     lr_output_message
(“值为:%s”,lr_eval_string(“{MyOutputParam}”)));
   i = i + 1;
     }}