Example Showing Batching of Return Values (Continuous Queries)

The example is the same as the simple continous query example, with the addition of an order by clause in the query text, to show batching behavior. Only the output and function calls differ.

Create the Query

Query.create("report853", "select agent_name, total_sales, zipcode from /Concepts/Sales order by agent_name");

Sample Output

  • Mary Smith makes a sale.
    C123: Agent Mary Smith sold $15063.28 in 94304. @@@@
    C123: --------
  • Time passes… Robert Ng makes a sale.
    C123: Agent Mary Smith sold $15063.28 in 94304. @@@@
    C123: Agent Robert Ng sold $14983.05 in 94304. @@@@
    C123: --------
  • Time passes… Jose Ortiz makes a sale.
    C123: Agent Jose Ortiz sold $16244.78 in 94304. @@@@
    C123: Agent Mary Smith sold $15063.28 in 94304. @@@@
    C123: Agent Robert Ng sold $14983.05 in 94304. @@@@
    C123: --------
    C123: ========

Function Calls

The following example shows the parameter values for each function call.

As a reminder: the first Boolean indicates whether the batch has ended or not; the second Boolean indicates whether the execution has ended or not.

Mary Smith makes a sale.
MyRF(clbk, false, false, ["Mary Smith", 15063.28, 94304], "@@@@")
MyRF(clbk, true, false, null, "@@@@")
Time passes… Robert Ng makes a sale.
MyRF(clbk, false, false, ["Mary Smith", 15063.28, 94304], "@@@@")
MyRF(clbk, false, false, ["Robert Ng", 14983.05, 94304], "@@@@")
MyRF(clbk, true, false, null, "@@@@")
Time passes… Jose Ortiz makes a sale.
MyRF(clbk, false, false, ["Jose Ortiz", 16244.78, 94304], "@@@@")
MyRF(clbk, false, false, ["Mary Smith", 15063.28, 94304], "@@@@")
MyRF(clbk, false, false, ["Robert Ng", 14983.05, 94304], "@@@@")
MyRF(clbk, true, false, null, "@@@@")
MyRF(clbk, true, true, null, "@@@@")
Note: The Query.Statement.executeWithBatch Callback() function works in a similar way, except that the callback rule function is called once for each batch, and the results are sent as an array of rows.