Execute ZCQL Query

Construct the Query

You must construct a ZCQL query on the required data set before you execute it. A sample SELECT query is shown below:

Copied//Create a query to execute
var query = 'SELECT * FROM ShipmentData';

Execute the Query

The query object created in the step above is passed to the executeZCQLQuery() method. The zcql reference used here is the component instance defined earlier.

This will return a promise which will be resolved to an object. The content key will contain the array of row objects.

Copied//Execute the query by passing it
var zcql = catalyst.ZCatalystQL;
 var zcqlPromise  = zcql.executeQuery(query);
zcqlPromise
        .then((response) => {
            console.log(response.content);
        })
        .catch((err) => {
            console.log(err);
        });

A sample response that you will receive is shown below. The response is the same for both versions of Web SDK.

Copied[
  {
    AlienCity: {
      CREATORID: "2136000000006003",
      MODIFIEDTIME: "2021-08-13 13:49:19:475",
      CREATEDTIME: "2021-08-13 13:49:19:475",
      CityName: "Dallas",
      ROWID: "2136000000008508"
    }
  },
  {
    AlienCity: {
      CREATORID: "2136000000006003",
      MODIFIEDTIME: "2021-08-16 15:55:32:969",
      CREATEDTIME: "2021-08-16 15:55:32:969",
      CityName: "Houston",
      ROWID: "2136000000011002"
    }
  },
  {
    AlienCity: {
      CREATORID: "2136000000006003",
      MODIFIEDTIME: "2021-08-16 17:03:01:507",
      CREATEDTIME: "2021-08-16 16:29:10:499",
      CityName: "Austin",
      ROWID: "2136000000011011"
    }
  }
]