The following example selects records from a file 50 rows at a time, into a primitive object.
pjs.connect("*LOCAL"); var c1 = pjs.allocStmt(); pjs.executeDirect(c1, "select prid, prname, prdesc from demolib/productsp order by prid", "c1"); var obj; if (SQLSTATE == '00000') { obj = pjs.fetch(c1, 50); while (SQLSTATE == '00000') { for (var i = 0; i < SQLERRD[3]; i++) { console.log(obj[i]); } obj = pjs.fetch(c1, 50); } } pjs.close(c1); pjs.disconnect()