pjs.hasMoreRows()
This API indicates whether or not the database has signaled that the end of the result set has been reached for the most recent fetch on the passed statement handle. The database signals the end of the result set when attempting to fetch a row before/after the first/last row in the result set.
The API can also be called in the form of a method attached to a statement object as follows: stmt.hasMoreRows().
Parameters
Statement handle returned from pjs.prepare() or pjs.allocStmt(). The statement handle must reference a SELECT statement that has been successfully executed using either pjs.execute() or pjs.executeDirect() and fetched from at least one time using pjs.fetch() or one of its variants.  This parameter is omitted if the API is called as a statement method.
Return Value
Boolean false if the database has signaled the end of the result set, otherwise true is returned.Â
Example
Select all rows from SYSTABLES
pjs.define("systables", { type: "data structure", qualified: true, dim: 100, elements: {
"table_name": { type: "char", varying: true, length: 128},
"table_text": { type: "char", varying: true, length: 50 }
}});
var stmt = pjs.allocStmt();
pjs.executeDirect(stmt, "select table_name, table_text from qsys2/systables");
var total = 0;
if (sqlcode === 0) {
 while (pjs.hasMoreRows(stmt)) { // while (stmt.hasMoreRows()) { is also valid syntax
pjs.fetch(stmt, systables, 100);
for (var idx = 1; idx <= pjs.rowCount(stmt); idx++) {
console.log("(%d) %s %s", total + idx, systables[idx].table_name, systables[idx].table_text);
}
total += pjs.rowCount(stmt);
}
}
pjs.close(stmt);
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!