LoadRunner solutions support the Oracle® - 2 Tier protocol to simulate communication between Oracle® Client and Oracle® Database.
The protocol uses C-language APIs, and the scripting flow can be challenging.
Another option is a generic set of database functions (lr_db_... functions) that are used in other protocols (https://admhelp.microfocus.com/vugen/en/latest/help/function_reference/Content/FuncRef/c_vuser/etc/lrFuncRef_c_Db_Functions.htm).
Similar functionality can be achieved with the DevWeb protocol by incapsulating the node-oracledb add-on for Node.js (https://www.npmjs.com/package/oracledb).
The module is open source and maintained by Oracle® Corp.
Node-oracledb supports basic and advanced features of Oracle® Database and Oracle® Client.
It is stable and well documented.
We recommend using the latest version (>=6.5.0).
Install node-oracledb module into the DevWeb script folder from the npm registry (for details, see https://admhelp.microfocus.com/lrd/en/latest/help/Content/DevWeb/DW-libraries.htm) and add the following line to the script:
const oracledb = require('oracledb')
Now you can connect to the database, execute SQL statements, and manipulate the data using JavaScript code and DevWeb SDK functions.
Below is a sample code:
// https://www.npmjs.com/package/oracledb // https://node-oracledb.readthedocs.io/en/latest/index.html let T001 = new load.Transaction("Connect DB"); let T002 = new load.Transaction("Get random Persons (1%)"); let T003 = new load.Transaction("Disconnect DB"); const oracledb = require('oracledb'); oracledb.autoCommit = true; oracledb.outFormat = oracledb.OUT_FORMAT_ARRAY; // oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT; oracledb.maxRows = 50; let connection; let persons; let selectRandomSQL = `SELECT * FROM PERSONS SAMPLE(1)`; let selectPersonsCountSQL = `SELECT count(*) FROM PERSONS`; load.initialize("Initialize", async function () { load.log(`oracledb client version: ${oracledb.versionString}`); try { T001.start(); connection = await oracledb.getConnection ({ user : "...username...", password : "...password...", connectString : "<Oracle Database host>/<Oracle Database service>" }); T001.stop(load.TransactionStatus.Passed); load.log(`Connected to ${connection.dbName}.${connection.dbDomain} - v.${connection.oracleServerVersionString}`); } catch (err) { load.log(err,load.LogLevel.error); T001.stop(load.TransactionStatus.Failed); load.exit(load.ExitType.stop, "Connect to DB failed"); } }); load.action("Action", async function () { try { T002.start(); const randomPersons = await connection.execute(selectRandomSQL); T002.stop(load.TransactionStatus.Passed); load.log(JSON.stringify(randomPersons.rows,null,4)); } catch (err) { load.log(err,load.LogLevel.error); T002.stop(load.TransactionStatus.Failed); load.exit(load.ExitType.stop, "Cannot get records from database"); } }); load.finalize("Finalize", async function () { if (connection) { try { T003.start(); await connection.close(); T003.stop(load.TransactionStatus.Passed); } catch (err) { load.log(err,load.LogLevel.error); T003.stop(load.TransactionStatus.Failed); } } });