Execute with Callback Function

When you use the Query.Statement.executeWithCallback() function, the agent calls the specified callback rule function once for each row of data generated. The row of data is provided as an array of columns.

The callback rule function is called in the following circumstances:

  • Once for each row of data generated by the query.
  • At the end of a batch of rows (continuous queries only). A blank row with the isBatchEnd flag is sent.
  • Once, when there are no more results, indicating the end of the results (snapshot queries) or that the statement was closed or the query deleted (continuous queries). See Statement Closing and Query Definition Deletion.

You can provide a closure object when executing the statement. The closure object is provided to each rule function call. It can contain anything useful in the execution context. For example, you can use an object array to accumulate each row of results returned in each callback rule function call.