After you define the internal procedures for dataset event handlers, you associate each handler and a named event with a particular dataset, temp-table buffer, or query object, in the code that fills or updates the dataset. In the code you first load the external procedure file that contains the internal procedures as a persistent procedure into the AVM. Then, you associate each internal procedure you want to use as a dataset event handler for a named event with its dataset object. The named event can be BEFORE-FILL, AFTER-FILL, BEFORE-ROW-FILL, AFTER-ROW-FILL, ROW-CREATE, ROW-UPDATE, ROW-DELETE, FIND-FAILED, OFF-END, or SYNCHRONIZE.

You use the SET-CALLBACK-PROCEDURE( ) method to establish this association.

The following is an example of server-side initialization code that fills the dataset at runtime. A handle for the procedure that holds the dataset event handlers is defined. The external procedure is run persistently and sets the handle to the procedure. The ttOrder temp-table is associated with the AFTER-ROW-FILL event handler, AdjustCarrier.

/* AppCode.p */
						
/* define the procedure handle */
VAR HANDLE hEventHandlers.
. . .
/* load the persistent procedure and set the procedure handle*/
RUN dsOrderOrderLine_EventHandlers.p PERSISTENT SET hEventHandlers.
. . .
/* associate the event handler with after-row-fill event */
BUFFER ttOrder:SET-CALLBACK-PROCEDURE(
    "AFTER-ROW-FILL","AdjustCarrier",hEventHandlers).

When you no longer need the persistent procedure, you should always delete it using the DELETE PROCEDURE statement.

See also

Event procedures for ProDataSets in Use ProDataSets