The following example selects fetches records from a file row-by-row, a table one at a time into specific fields.:
Code Block |
---|
|
// These definitions should match the table column definitions
pjs.define("prid", { type: "packed decimal", length: 5, decimals: 0, initValue: 105 });
pjs.define("prname", { type: "char", length: 30 });
pjs.define("prdesc", { type: "char", length: 60 });
pjs.connect("*LOCAL");
var c1 = pjs.allocStmt();
pjsc1.executeDirect(c1, "selectSELECT prid, prname, prdesc fromFROM demolib/productsp orderORDER byBY prid", "c1");
if (SQLSTATEsqlstate == '00000') {
pjs.fetch(c1, prid, prname, prdesc);
while (c1.hasMoreRows()) {
while (SQLSTATE == '00000') {
// Process fetched data here
pjs.fetch(c1, prid, prname, prdesc);
}
}
pjsc1.close(c1);
pjs.disconnect(); |