Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

This API prepares a statement to execute.

  • You will only need to prepare a statement if you have markers in the SQL WHERE clause. You may use pjs.executeDirect() otherwise.
  • You must have a connection to a database before using this API.
Parameter
  1. SQL statement string
  2. Cursor name

Return Value

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

Exception Handling

An Error instance will be thrown with the following properties:

  • message - The IBM i message text.
  • error - The message id.
  • help - The message help text.
Example
pjs.define("productsp_out", { type: 'data structure', qualified: true, dim: 50, elements: {
  "prid": { type: "packed decimal", length: 5, decimals: 0, initValue: 105 },
  "prname": { type: "char", length: 30 },
  "prdesc": { type: "char", length: 60 }
}})
 
pjs.define("searchQuery", { type: "char", length: 30 });
 
var c1;
pjs.connect("*LOCAL");
pjs.clear(productsp_out);


searchQuery = '%' + 'Garmin' + '%';
c1 = pjs.prepare("select prid, prname, prdesc from demolib/productsp where prdesc like ? order by prid", "c1");
pjs.bindParameters(c1, [
  [searchQuery.trim(), pjs.SQL_PARAM_INPUT]
]);
pjs.execute(c1);
 
pjs.fetch(c1, productsp_out, 50);
 
pjs.close(c1);
pjs.disconnect();


Requirements

This API requires the Profound.js Connector module.

  • No labels