Action: EXECUTE_SQL

The action EXECUTE_SQL allows fetching and saving data from local content SQLite (Android - yourProject/assets/yourapp_content.sqlite, iOS - yourProject/Resources/assets/yourapp_content.sqlite). See Working with local content database for more information. The advantage of using light weight SQLite database for storing and retrieving data is that it is many times faster than doing it with the remote server.

The action can be attached to the following elements <screen_deck>, <screen>, <control>

Attributes Value Mandatory
action_name EXECUTE_SQL Yes
event_list comma separated list of events, eg: TAP Yes
target SQL query. The query can contain parameters like <CONSTANT:>, <GLOBAL:property_name> Yes
input_parameter_list comma separated list of values to be passed to the query parameters. The values could be CONSTANTS, could be fetched from Global Property or fetched from control values using their field_name No
target_parameter_list comma separated list of parameters to be passed to the query No

Example 1

In the example Fetch local data in XMADL screen element, the action is attached to the screen. It is executed when the screen resumes.

Example 2

In the example Fetch local data in XMADL control element, the action is attached to the LIST control. When the screen resumes, the SQL query executes and create a database structure called ‘CURSOR’. The cursor is attached to the LIST control. Upon scrolling the LIST items, the data is fetched from the database immediately. When the LIST control’s data source is a CURSOR, the whole data set is not loaded into the memory, however it is fetched from the local database on the need basis. In this way, the LIST control can work with tens of thousands of rows.

More examples

More examples can be found in the following tutorials.