Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..
660 views

TruClient using Param from c-function db code in type step

Jump to solution

Hi,

I'm using truclient c-function.c to connect to SQL Database and select a field and store to outparam in lr_db_getvalue() {InvIDValue}. 

I don't know how to then use the value stored in InvIDValue and Type it into a search field using the step of the Arguments Value. 

tc-step.JPG

Here is the replay log of the steps, in step 4.2 Type is literally typing in InvIDValue.

i have also included the db connection c-function code if it helps...

really need to know asap!!

Virtual User Script started at : 2017-06-16 06:06:26
TruClient Replay for LoadRunner 12.53.0, build 1203. OS: Windows 2012 R2, Browser: Firefox, initialized on 2017/06/16 at 06:06:14 (0000.000s)
Running Vuser...
Starting iteration 1.
t=00012603ms: ** 1: Evaluate C function connect_db ** started    [MsgId: MMSG-205180]
DB Connection "GetInvID" started ... Wait ....
SQL Statement  execution "GetInvID" started
================================================
Update query returned 1 row(s).
Get db value "GetValue" started
================================================
The InvID is: 00890b37-cd86-48ed-aaa0-d4f58166564b
t=00013467ms: ** 1: Evaluate C function connect_db ** successfully completed with end event 'Action completed'    [MsgId: MMSG-205180]
t=00013975ms: ** 2: Navigate to "xyzzzzz.com" ** started    [MsgId: MMSG-205180]
t=00016933ms: ** 2: Navigate to xyzzzzz.com ** successfully completed with end event 'Step synchronous network completed'    [MsgId: MMSG-205180]
t=00016941ms: ** 4: search (1) ** started    [MsgId: MMSG-205180]
t=00017449ms: ** 4.1: Click on Search combobox ** started    [MsgId: MMSG-205180]
t=00017687ms: ** 4.1: Click on Search combobox ** successfully completed with end event 'Action completed'    [MsgId: MMSG-205180]
t=00018193ms: ** 4.2: Type InvIDValue in Search combobox ** started    [MsgId: MMSG-205180]
t=00020395ms: ** 4.2: Type InvIDValue in Search combobox ** successfully completed with end event 'Action completed'    [MsgId: MMSG-205180]
t=00021198ms: ** 4.4: Press Enter key on Search combobox ** started    [MsgId: MMSG-205180]
void connect_db()
{
	int NumRows = 0;
    
	lr_db_connect("StepName=GetInvID",
    	"ConnectionString=Initial Catalog=DB000;Data Source=SQLSERVER;user id =schmuck ;password = XMXMX" ,
    	"ConnectionName=myConnection",
    	"ConnectionType=SQL",
    	LAST);
    	


	NumRows = lr_db_executeSQLStatement("StepName=GetInvID",
        "ConnectionName=myConnection", 
        "SQLStatement=select top 1 ID from [dbo].[INV_DATA] where time_created >= dateadd(hour, -10000, getdate());", 
        "DatasetName=MyDataSet", 
        LAST);
        
    lr_output_message("Update query returned %d row(s).", NumRows); 
	
    if (NumRows>0){ 
		lr_db_getvalue("StepName=GetValue", 
			"DatasetName=MyDataSet", 
			"Column=ID", 
			"Row=next", 
			"OutParam=InvIDValue", 
			LAST ); 
    	
		lr_output_message("The InvID is: %s", lr_eval_string("{InvIDValue}") ); 
		
		}
		else {
			lr_error_message("InvID not found in Table.");
			lr_abort();
		}

}

 

If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution. Don't forget to Kudo!!
0 Likes
1 Solution

Accepted Solutions
Highlighted
Trusted Contributor.
Trusted Contributor.

Re: TruClient using Param from c-function db code in type step

Jump to solution

Hi, 

Thanks for your question.  You may try this:

  • Select "JavaSript" option from the TruClient value input field
  • Call API: LR.getParam("YourOutParamName"); 

 

View solution in original post

2 Replies
Highlighted
Trusted Contributor.
Trusted Contributor.

Re: TruClient using Param from c-function db code in type step

Jump to solution

Hi, 

Thanks for your question.  You may try this:

  • Select "JavaSript" option from the TruClient value input field
  • Call API: LR.getParam("YourOutParamName"); 

 

View solution in original post

Highlighted
Outstanding Contributor.. Outstanding Contributor..
Outstanding Contributor..

Re: TruClient using Param from c-function db code in type step

Jump to solution

Thanks for your response.  I instead used web html protocol to solve the problem.

I just tried your suggestion to my original query and in my test it works!

ggggg.JPG

If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution. Don't forget to Kudo!!
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.