快捷搜索:  as  2018  FtCWSyGV  С˵  test  xxx  Ψһ  w3viyKQx

和记娱乐ag手机版_机器人论坛



在Loadrunner中也供给了C对数据库操作的相关功能函数,以下这些数据库功能函数只能用于Web Services协议。

lr_db_connect

连接数据库

lr_db_disconnect

断开数据库的连接

lr_db_executeSQLStatement

履行SQL语句

lr_db_dataset_action

对数据库履行操作

lr_db_getValue

从数据集中检索值

各函数语法如下:

lr_db_connect("StepName", "ConnectionString=", "ConnectionName=", "ConnectionType=", LAST);

lr_db_disconnect("StepName=", "ConnectionName="和记娱乐ag手机版, LAST);

lr_db_executeSQLStatement("StepName=", "ConnectionName=", "SQLStatement=", ["DatasetName=",] LAST);

lr_db_dataset_action("StepName和记娱乐ag手机版=", "DatasetName=", "Action=", LAST);

lr_db_getValue("StepName=", "DatasetName=", "Column=", "Row=", "OutParam=", LAST);

下面以oracle数据库为例:

Action()

{

int NumRows=0;

int i=1;

//建立数据库连接

lr_db_connect("StepName=DatabaseConnection",

"ConnectionString=Provider=OraOLEDB.Oracle.1;Password = test ;Persist Security Info=True; User ID= test ; Data Source = betadb ; Server = 172.19.188.191",

"ConnectionName=InvDatabaseConnection",

"ConnectionType=OLEDB",

LAST);

//履行SQL语句

NumRows = lr_db_executeSQLStatement("StepName=PerformQuery",

"ConnectionName=InvDatabaseConnection",

"SQLStatement=SELECT cons_no,cons_id FROM c_cons where rownum",

"DatasetName=MyDataset",

LAST);

lr_output_message("The query returned %d rows.", NumRows);

//打印出结果

lr_db_dataset_action("StepName=PrintDataset",

"DatasetName=MyDataset",

"Action=PRINT",

LAST);

//使用轮回检索数据值

while (i10) {

lr_db_getvalue("StepName=GetValue",

"DatasetName=MyD和记娱乐ag手机版ataset",

"Column=CONS_NO",

"Row=next",

"OutParam=MyOutputParam",

LAST);

lr_output_message("The value is: %s", lr_eval_string("{MyOutputParam}") );

i=i+1; }

//开释结果

lr_db_dataset_action("StepName=RemoveDataset",

"Datase和记娱乐ag手机版tName=MyDataset"和记娱乐ag手机版,

"Action=REMOVE",

LAST);

//断开数据库连接

lr_db_disconnect("StepName=Disconnect",

"ConnectionName=InvDatabaseConnection",

LAST);

return 0;

}

您可能还会对下面的文章感兴趣: