Page tree
Skip to end of metadata
Go to start of metadata

This API prepares a statement to execute.

You only need to prepare a statement if you have parameter markers, identified by ? (question mark) symbols, in the SQL. You may use pjs.executeDirect() otherwise.


This API can accept an optional database connection definition object to select between multiple database connections. To select the database connection, call pjs.getDB() and pass the result as the first parameter, followed by the parameters documented below. If a database connection definition object is not passed, the default database connection is used.

  1. SQL statement string
    1. The SQL statement must be valid for the database you are using

Return Value

This method will return a handle which much be used again in other statements.

Exception Handling

SQL diagnostics are reported in the SQLCA:

SQLCA fields are defined in Profound.js programs with the names in lowercase. sqlcode will be set to zero if execution was successful.

var table = "productsp";
pjs.define("productsp_out", { type: 'data structure', qualified: true, dim: 50, extName: table  });
pjs.define("searchQuery", { type: "char", length: 30 });

searchQuery = '%' + 'Garmin' + '%';
var c1 = pjs.prepare("SELECT * FROM productsp WHERE prdesc LIKE ? ORDER BY prid");
pjs.fetch(c1, productsp_out, 50);


When using an IBM i database, this API requires the Profound.js Connector module.