AEXECUTE
Contents
Description
This function will queue up a query and run it asynchronously in a background thread (rather than the script waiting for it to complete like the EXECUTE function). Once the query has been executed, a specified callback function will run.
Note 1: An open database connection is required for this function to work correctly. See the CONNECT function for information regarding the opening of a database connection.
Note 2: The AEXECUTE and EXECUTE functions are intended to run SQL commands that do not return any results (such as DELETE or UPDATE). For commands that return results (that you want to then read back) see the AQUERY and QUERY functions.
Valid for the following objects:
Syntax
AEXECUTE function, command
Argument | Type | Description | ||||||||
function | string | A script function to call when the command has been executed.
| ||||||||
command | string | The SQL command to execute. |
Return Values
This function returns one of two values when executed. See the table below for the meanings of the return values:
Return Value | Description |
0 | Command has not been successfully queued. |
1 | Command has been successfully queued. |
Examples
// // Queues up an SQL command. // [FUNCTION f_execute] SERV.LOG Deleting all rows from table 'tbl_name'. IF (<DB.AEXECUTE f_execute_callback, DELETE FROM tbl_name> == 0) SERV.LOG Failed to queue command. ELSE SERV.LOG Command queued. ENDIF RETURN // // This function will be called when the query has been executed. // [FUNCTION f_execute_callback] IF (<ARGN2> == 0) SERV.LOG The command failed to execute. (<ARGS>) ELSE SERV.LOG The command succeeded. (<ARGS>) ENDIF RETURN