Thursday, August 27, 2015

Execute DB queries in loadrunner webservices protocol

Loadrunner web-services protocol can be used to execute DB queries



Action()
{
    int retval;
    int NumRows=0;

   retval = lr_db_connect("StepName=DatabaseConnection",
        "ConnectionString=dsn=Test;userid=test; password=Test",
        "ConnectionName=food",
        "ConnectionType=ODBC",
        LAST );
   
     lr_start_transaction("Report");

 
NumRows = lr_db_executeSQLStatement("StepName=PerformQuery",
    "ConnectionName=foodb",
    "SQLStatement="
    "select count(*) indv_knt, count(distinct lbi_hshl_id) hshl_knt,"
    "count(distinct best_dmid_num) dmid_knt \r\nfrom "
     "CDMZDATAVIEW.best_domestic_postal_addr where ctry_cd = 'US';",
    "DatasetName=MyDataset",
    LAST );
 
   lr_end_transaction("Report", LR_AUTO);
    lr_db_dataset_action("StepName=PrintDataset",
        "DatasetName=MyDataset",
        "Action=PRINT",
         LAST );   

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

  
    
    return 0;
}


1 comment:

  1. hi,

    when i start this webservices protocol at controller, i get 0ms everytime at lr_start_transaction("Report"); step even NumRows returns 50000 records.

    could you help me please?

    ReplyDelete