Versions Compared

Key

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

...

  1. Handle from a prepared statement. This parameter can be omitted if the API is called as a statement method.

Exception Handling

An Error instance will be thrown with the following properties:

...

SQL diagnostics are reported in the SQLCA:

https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_73/db2/rbafzfielddescsqlca.htm

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

Example
Code Block
languagejavascript
titleCalled directly
var searchTerm = '%' + search + '%';
var sql = 'SELECT * FROM products WHERE prname LIKE ? OR prdesc LIKE ?';

var c1 = pjs.prepare(sql);
pjs.setStmtAttr(c1, SQL_ATTR_CURSOR_SCROLLABLE, SQL_TRUE);
pjs.bindParameters(c1, [searchTerm, searchTerm]);

pjs.execute(c1);

...

Code Block
languagejavascript
titleCalled as a method
var searchTerm = '%' + search + '%';
var sql = 'SELECT * FROM products WHERE prname LIKE ? OR prdesc LIKE ?';

var c1 = pjs.prepare(sql);
c1.setAttr(SQL_ATTR_CURSOR_SCROLLABLE, SQL_TRUE);
c1.bindParameters([searchTerm, searchTerm]);

c1.execute();


Requirements

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