Fetches the last row from the cursor associated with the passed statement handle.
Parameters
- The first parameter is a statement handle returned from pjs.allocStmt() or pjs.prepare(). The statement handle must be executed with pjs.execute() or pjs.executeDirect() before it can be used to fetch rows.
- Optionally, one or more Profound.js field names can be passed. If field names are passed, they will be bound to columns in the resulting rows and populated by this API if the fetch is successful. If no Profound.js field names are passed, this API will return fetched rows as an Array of Objects with keys named for the columns and values as JavaScript Numbers for numeric columns, and JavaScript Strings for all other column types. An empty Array is returned if the fetch is not successful.
- Following the optional field names, a Number can be passed that specifies the number of rows to fetch. If not passed, 1 row will be fetched.
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
c1 = pjs.allocStmt(); pjs.setStmtAttr(c1, SQL_ATTR_CURSOR_SCROLLABLE, SQL_TRUE); pjs.executeDirect(c1, "select prid from demolib/productsp order by prid"); pjs.fetchLast(c1, prid); pjs.close(c1);
Requirements
This API requires the Profound.js Connector module.