Versions Compared

Key

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

...

The API can also be called in the form of a method attached to a statement object as follows: stmt.bindParameters().

 

Parameters
  1. The handle created by pjs.prepare(). This parameter is omitted , if the API is called as a statement method.
  2. An array of parameters for each SQL parameter marker. Each element in the array must be another array, where the first element is the value of the parameter and the second is the parameter type. For example:
    • [[paramA, SQL_PARAM_INPUT], [paramB, SQL_PARAM_INPUT]]

      If an array is not used, the parameter is automatically converted to an array. If the parameter type is not passed, SQL_PARAM_INPUT is assumed.

Example
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);
 
 
searchQuery = '%' + 'Garmin' + '%';
var c1 = pjs.prepare("select prid, prname, prdesc from demolib/productsp where prdesc like ? order by prid");
pjs.bindParameters(c1, [
  [searchQuery.trim(), pjs.SQL_PARAM_INPUT]
]);
pjs.execute(c1);
 
pjs.fetch(c1, productsp_out, 50);
 
pjs.close(c1);
pjs.disconnect();

...