Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • You will only need to prepare a statement if you have markers in the SQL WHERE clause within the statement. 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.

...

Code Block
languagejavascript
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);
 
var statementHandle


searchQuery = '%' + 'Garmin' + '%';
c1 = pjs.prepare("SELECT * FROM PJSTEST/PRODUCTSP WHERE PRIDselect 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.