Skip to main content

executeQuerySQL

Executes an SQL query in the local database and makes the queried fields available in the parameters of the onSuccess action.

Field Configurations

KeyTypeDescriptionDefault Value
"params" (required)Objectundefinednull

Parameters

KeyTypeDescriptionDefault Value
"async"BooleanSpecifies whether the action should perform asynchronously.null
"onError"StringEvent that is fired of case of an error.null
"onErrorType"OnErrorTypeType of event that will be fired on error.null
"onSuccess"StringEvent that is fired in case of success.null
"onSuccessType"OnSuccessTypeType of event that will be fired on success.null
"sql" (required)StringThe SQL query that is to be executed.null
"sqlParams"ArrayThe parameters for the SQL query.null

Inherited

From Base Action

Base Action

Field Configurations

KeyTypeDescriptionDefault Value
"dynamicParams"ObjectDynamic params to retrieve data from a specific context e.g. a userSetting.null
"leadingDelimiter"StringThe leading mustache delimiter to use.null
"params"Object,ArrayObject containing the properties of the action.null
"trailingDelimiter"StringThe trailing mustache delimiter to use.null
"type"StringType name of the action.null

Examples

Example 1: Execute an SQL query

Goal: Create an executeQuerySQL action using the resulting fields in the onSuccess event.

To achieve this the following code can be used:

{
"type": "executeQuerySQL",
"params": {
"sql": "SELECT name FROM vehicles WHERE type = ?1",
"sqlParams": [
"car"
],
"onSuccess": "successEvent",
"onError": "errorEvent"
}
}

The sql and sqlParams parameters specify queried fields.

Within the onSuccess event, the resulting fields can be accessed as follows (depending on the OS of the device, both results.0 and results.first may both be required):

{
"type": "successEvent",
"actions": [
{
"type": "showMessage",
"params": {
"text": "{{results.0.name}}{{results.first.name}}"
}
}
]
}

Result:

An executeQuerySQL action has been created.