You can also use an event handler to implement batching of data from the server. Application performance is affected by the amount of data sent over the network. If too large a number (batch) of records are sent at once, performance may be impacted. If too few records are sent, more round trips are needed to retrieve the required data.

Batching data means you retrieve a subset of data from the server in separate server calls until you retrieved the required data. The batching capabilities of datasets allow you to tune for application performance. Depending on your application, user requirements, and your network, you can customize the dataset batch size to best meet your needs.

A recommended way to implement batching is to use the OFF-END query event in the client code. For example, you may want to view the first 10 records in a table that are retrieved from the server, and when Next is clicked, the next 10 records are retrieved from the server and displayed. Retrieving small batches of data allows you to see data immediately without having to wait for the entire table to be returned from the server. As your query iterates through the retrieved data, it detects the QUERY-OFF-END condition when it reaches the end of the last retrieved record. The QUERY-OFF-END condition triggers the OFF-END event. When the OFF-END query event is triggered the OFF-END event handler attempts to retrieves the next batch of data from the server. If there is no more data to retrieve the query ends, otherwise the query continues.

To implement data batching, you add code in the client and the server as follows:

  • In the client, you write code to retrieve the initial batch of data, specifying the batch size, and the ROWID for starting the batch.
  • In the server, you write code to set the batch size for data retrieval, set the starting ROWID, retrieve the data, and return the ROWID of the next record to be retrieved.
  • In the client, you write code to associate the query with the OFF-END query event. Then, in the code, your query checks if it has reached the end of the iteration. If the QUERY-OFF-END condition is TRUE, the OFF-END event is triggered. You write the OFF-END handler procedure to retrieve the next batch of data, specifying the starting ROWID, and reset the condition.

See also

Batch Data with ProDataSets in Use ProDataSets

OFF-END event in ABL Reference