pjs.execute()
This API executes a prepared statement. It should be be called after parameter binding.
The API can also be called in the form of a method attached to a statement object as follows: stmt.execute().
Parameters
Handle from a prepared statement. This parameter can be omitted if the API is called as a statement method.
Exception Handling
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
Called 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);
Called 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
When using an IBM i database, this API requires the Profound.js Connector module.
Some documentation pages have recently moved to a new section: Profound AppDev. If you are having trouble finding specific pages, try the documentation search capability or reach out to our Support team!