runQuery


Purpose

This method provides access (with single record granularity) to data saved in the Client Store.

Signature

runQuery( query, parameters, targetTableName, onSuccess, onFailure )

Returns

This method does not return anything.

Parameters

Name Description Type Use
query

An SQL query that relies on the SQLite syntax.

Note

The following restrictions apply only when the targetTableName parameter is passed:

  • Queries must operate on tables created according to the schema received through datasync.

  • Do not use aliases instead of table or column names.

string required
parameters

An array of parameters, in the order of their appearance in the query. The types and formatting of the parameters must match the following rules:

  • text values must be given as strings

  • numerical values must be given as numbers

  • boolean values must be given as numbers, where 0 indicates "false" and 1 indicates "true"

The length of the array must match the number of the questionmark character occurrences in the query. If no parameters are used, an empty array must be passed.

object required
targetTableName A name of the target datapage. Used to obtain column types when formatting the result. If null or undefined, a raw SQL result is returned. string optional
onSuccess

A callback function, called when the query succeeds. It passes a results object, being an array of selected rows. Each row is a column name/column value map. Unless the targetTableName parameter is null or undefined, values are formatted as follows:

  • text values are given as strings

  • numbers are written in decimal notation with a dot used as the decimal separator

  • boolean values are represented as either "true" or "false"

The order of returned rows is maintained only if the query includes the "ORDER BY" clause.

function required
onFailure A callback function, called when the operation fails. Passes an error code, as defined in the Constants table in the Client Store article, and an error message. function required

Related topics

Client Store
Legal notice | Copyright © 2018 and Confidential to Pegasystems Inc. All rights reserved
Pega Community | Feedback
Advanced...