Established Member.. Kumar74
Established Member..
255 views

How to incorporate database calls in middle of tru client and web scripts

I have a requirement for web (HTTP/HTML) and Truclient scripts to call database and use the values from the query result in next steps (in the same script) to fulfill the flow. How to call DB in middle of the script (truclient and web). Please share me if you have any code examples .

Thanks,

Kumar

0 Likes
4 Replies
Absent Member.. Alftio Absent Member..
Absent Member..

Re: How to incorporate database calls in middle of tru client and web scripts

Greetings,

For Web (HTTP/HTML) base script you can combine it using the muti-protocol and create a Web (HTTP/HTML)+ODBC or Web (HTTP/HTML)+Oracle -2 Tier or Web (HTTP/HTML)+Oracle NCA and execute calls to the database for get specific values which can act like parameters in other part of the solution.

http://vugenhelp.saas.hpe.com/en/12.53/help/WebHelp/Content/VuGen/tocs/133850_toc_db.htm

Database functions

http://lrhelp.saas.hpe.com/en/12.53/help/function_reference/Content/Database/etc/lrFuncRef_DBS_Database_Vuser_Funcs.htm

Regarding TruClient you can use JavaScript code inside an "Evaluate JavaScript" from the TC toolbox.

http://tchelp.saas.hpe.com/en/12.53/Content/TruClient/procedures/_tc_examples_work_with_dyamic_values.htm

http://stackoverflow.com/questions/11027982/how-to-get-data-from-database-in-javascript-based-on-the-value-passed-to-the-fun

 

Kind regards,

 

 

 

0 Likes
ldr-LoadRunner Super Contributor.
Super Contributor.

Re: How to incorporate database calls in middle of tru client and web scripts

Kumar,
In TruClient, if you had the necessary C libraries/code, you could also call those functions using an "Evaluate C" step. This would be an alternative to writing the necessary dadtabase interaction code using JavaScript.

For your Web Protocol needs, you could use Web Services protocol instead and use the "lr_db_connect" and "lr_db_executeSQLStatement". This can be used with the following types of data providers: SQL (meaning, the Microsoft Native SQL Provider), OLEDB (use OLEDB for Oracle), ODBC and ORACLE.

So, for example: 

//Connect to DB Server
lr_db_connect("StepName=DatabaseConnection",
"ConnectionString=User ID=<USER>;PWD=<Password>;Initial Catalog=<DB Name>;Data Source=<IP Address or Machine name>;",
"ConnectionName=Connection_1",
"ConnectionType=SQL",
LAST );

//SQL Query
number = lr_db_executeSQLStatement("StepName=SelectStep",
"ConnectionName=Connection_1",
"SQLStatement=SELECT * FROM <TABLE>",
"DatasetName=MyDataSet",
LAST);

Please refer to the User Guide and Function Reference in VUGen for more details and examples.

HP Support

If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution.
0 Likes
Established Member.. Kumar74
Established Member..

Re: How to incorporate database calls in middle of tru client and web scripts

Thank you Daniel , let me go through this documentation.

Thanks a lot!!

 
0 Likes
Highlighted
Established Member.. Kumar74
Established Member..

Re: How to incorporate database calls in middle of tru client and web scripts

I have another question regarding this,

I have web (HTTP/HTML)  licenses (for eg: 500) and I do not have any licenses for web services or Oracle/NCA.

If I want to use these protocol with the combination of HTTP/HTML protocol, will it support?

Do I get any license issue for Oracle/web services?

Please clarify me.  Thanks

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.