The following example selects reads records from a file table 50 rows at a time , into a data-structure array.:
Code Block | ||
---|---|---|
| ||
pjs.define("productsp_out", { type: 'data structure', qualified: true, dim: 50, elements: { "prid": { type: "packed decimal", length: 5, decimals: 0, initValue: 105 }, "prname": { type: "char", length: 30 }, "prdesc": { type: "char", length: 60 } }}) pjs.connect("*LOCAL"); pjs.clear(productsp_out); var c1 = pjs.allocStmt(); pjsc1.executeDirect(c1, "selectSELECT prid, prname, prdesc fromFROM demolib/productsp orderORDER byBY prid", "c1"); if (SQLSTATE == '00000') { while (pjsc1.hasMoreRows(c1)) { pjs.fetch(c1, productsp_out, 50); for (var i = 1; i <= pjs.rowCount(c1); i++) { console.log({ id: productsp_out[i].prid, name: productsp_out[i].prname, desc: productsp_out[i].prdesc }); } } } pjsc1.close(c1); |