loadrunner如何实时获取数据库里的数据?
数据库 里的数据是不断更新的,那么lr在压测的时候,能实时获取数据库 里的数据吗?通过关联操作,能解决这一问题吗?
下面以oracle数据库为例:
Action()
{
intNumRows=0;
inti=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<10",
"DatasetName=MyDataset",
LAST);
lr_output_message("The query returned %d rows.", NumRows);
//打印出结果
lr_db_dataset_action("StepName=PrintDataset",
"DatasetName=MyDataset",
"Action=PRINT",
LAST);
//利用循环检索数据值
while(i<10) {
lr_db_getvalue("StepName=GetValue",
"DatasetName=MyDataset",
"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",
"DatasetName=MyDataset",
"Action=REMOVE",
LAST);
//断开数据库连接
lr_db_disconnect("StepName=Disconnect",
"ConnectionName=InvDatabaseConnection",
LAST);
return0;
} 很详细啊
页:
[1]