Tuesday 15 September 2015

The Saving results of SQL query to a LoadRunner parameter

The Saving results of SQL query to a LR parameter


Here is an example of how to save the results of a query to a loadrunner parameter. In this example I want to know the prod_code for a particular user whos user name is held in the parameter pUserID. To do this you have to add a lrd_ora8_save_col statement BEFORE the fetch statement.

lrd_ora8_handle_alloc(OraEnv1, STMT, &OraStm7, 0);
lrd_ora8_stmt(OraStm7, "select indiv,prod_code,last_up_seq from product_users"
"where indiv_uid = '{pUserID}'", 1, 32, 0);
lrd_ora8_exec(OraSvc1, OraStm7, 0, 0, &uliRowsProcessed, 0, 0, 0, 0, 0);
lrd_ora8_bind_col(OraStm7, &OraDef9, 1, &INDIVD10, 0, 0);
lrd_ora8_attr_set(OraDef9, CHARSET_FORM, "1", -1, 0);
lrd_ora8_bind_col(OraStm7, &OraDef10, 2, &PROD_CODE_D11, 0, 0);
lrd_ora8_attr_set(OraDef10, CHARSET_FORM, "1", -1, 0);
lrd_ora8_bind_col(OraStm7, &OraDef11, 3, &LAST_UPE_SEQ_D12, 0, 0);
lrd_ora8_save_col(OraStm7, 2, 1, 0, "prod_code");
lrd_ora8_fetch(OraStm7, -1, 15, &uliFetchedRows, PrintRow8, 2, 0, 0);

lrd_handle_free(&OraStm7, 0);

lr_message("The users product code is %s",lr_eval_string("{prod_code}"));

The second and third arguementare the column and row number with the 1,1 returns the value in the first column and the first row, The value is stored in the last arguement. Note that if no value is returned the error will be an unhelpful Parameter is not initialized.


LoadRunner Training in Bangalore
LoadRunner Training in Hyderabad
LoadRunner Online Training
LoadRunner Training in BTM
LoadRunner Training in Marathahalli
Best LoadRunner Training Institutes in Bangalore 
Best LoadRunner Training Institutes in India
Training Institutes in Bangalore

No comments:

Post a Comment