executeQuery()
Last updated 13/07/2022
The following code selects all employee names from the Employee table.
Example One
executeQuery()
let queryResults = five.executeQuery(`SELECT Name FROM Employee`);
Example Two
The following code uses an existing query in Five referenced by it's Action ID.
executeQuery() using the Query parameter
let queryResults = five.executeQuery(`EmployeesQueryActionID`);
Example Three
The following code selects five employee records from the Employee table.
executeQuery() using the optional Limit parameter
let queryResults = five.executeQuery(`SELECT Name FROM Employee`, 5);
Example Four
The following code selects all employee records with a post code of 4066. The Limit parameter is no longer optional when using variable arguments.
executeQuery() using 0 with the Limit parameter and variable arguments
const postCode = '4066';
let queryResults = five.executeQuery(`SELECT Name FROM Employee WHERE Employee.PostCode = ?`, 0, postCode);
Example Five
The following code selects the first five employee names that reside in the postcode 4066 using the optional Limit parameter and variable arguments."
executeQuery() with the optional Limit parameter and variable arguments.
const postCode = '4066';
let queryResults = five.executeQuery(`SELECT Name FROM Employee WHERE Employee.PostCode = ?`, 5, postCode);
Example Six
The following code uses an existing transaction in Five and executes the query against the transaction.
executeQuery() using an existing transaction and query
const tx = five.startTransaction(db);
let queryResults = five.executeQuery(tx, `SELECT Name FROM Employee`);