Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 3 Next »

The following example selects records from a file 50 rows at a time, into a data-structure array.

  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();
  pjs.executeDirect(c1, "select prid, prname, prdesc from demolib/productsp order by prid", "c1");

  if (SQLSTATE == '00000') {

    while (!pjs.isLastRow(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 
        });
      }
    }

  }

  pjs.close(c1);

  • No labels