Page tree

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


Using this API can significantly improve performance.  These SQL statements are all initiated at the same time, rather than one at a time.

Input Parameter

An array of SQL statements

  1. String - SQL statement
  2. Array - With the following elements [SQLStatement, token1, token2, etc...]
Returned Object

An array of objects,  In the below code example, qryResults will have 3 elements.

  • qryResults[0] - the results of running sql1
  • qryResults[1] - the results of running sql2
  • qryResults[2] - the results of running sql3

Each of those individual results is based on if that SQL statement was run successfully or not.  If successful, result will be an array of the data.  If not successful, result will be an object containing information about that failure.

Every SQL statement will be executed, and the result array sequence will match the parameter sequence.

Code Block
function getData(request, response) {
    let id =;
    let name =;

    let sql1 = "select count(*) as total from productsp";                                // Simple sql string
    let sql2 = ["select * from productsp"];                                              // Simple sql string
    let sql3 = ["select * from productsp where productid = ? or prname = ?", id, name];  // SQL with where condition

    let qryResults = pjs.parallelQueries([sql1, sql2, sql3]);

     // TheThis qryResultswill objectreturn isa anjson array with 3 elements, because there were 3 queries.
    // And withbecause each pjs.query returning an array -- thatthen makesthis qryResults andwould be an array of arrays.