Skip to end of metadata
Go to start of metadata

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

Compare with Current View Version History

« Previous Version 5 Next »

Profound.js Connector provides much of the same Record Level Access support when working with non IBM i database objects.  Below is a list of the functions that are not supported with these other database:

  • Using files with level checking
  • QTEMP
  • Record Locking
  • Fetching records by relative record number
  • Not all of the INFDS (Information Data Structure) values are available

For more information about RLA capabilities, see Record Level Access API.

 

To begin using RLA/SQL functions within your pjs programs:

Create the DbDefn module which enables you to use RLA functions in lieu of writing a lot of sql

 

 

To create a module we need to be able to name and describe some key parts of that table.

  1. File name --> example product.DbDefn.js
    1. Important notes:
      1. The file name must end with .DbDefn.js
      2. The first part of the name is how your pjs program will reference it :: "product"


 

Below is a simple table named PRODUCT that is keyed/ordered by a field called PRID.

 

 

is a file named: product.DbDefn.js and put it anywhere under the modules folder.  You will likely want to further organize these.

module.exports = {
  useSQL: true,
  dbObject: "product",
  format: "product",
  uniqueKey: [
    { field: "prid", ascending: true }
  ]
}

 

 

 

 

If you have an existing pjs program you don't have to do anything to it, as long as it does not use any of the non supported functions.

Here is a simple pjs program that reads all the records of a table.

function products() {
    pjs.defineTable("product", { read: true, keyed: true });
    product.positionTo(0);

    var data = [];
    var record = product.fetch();
    while (!pjs.endOfData()) {
        data.push(record);
        record = product.fetch();
    }
   
    console.log(JSON.stringify(data,null,2));
}

exports.run = products;


  • No labels