Dataset change events
- Last Updated: September 14, 2021
- 2 minute read
- OpenEdge
- Version 12.2
- Documentation
Dataset change events can occur in the server or in the client and are handled where they occur.
A change event is triggered when a record in a temp-table of a dataset is created, deleted, or updated. Change events are associated with a particular temp-table or temp-table buffer.
The following table lists the events that are triggered during a create, delete, or update operation:
| Event | When it occurs | Examples |
|---|---|---|
ROW-CREATE |
Immediately after the record is created, a ROW-CREATE
event occurs. The current buffer for the temp-table is available and contains
initial values as defined in the temp-table definition. |
|
ROW-DELETE |
Immediately before the temp-table record is deleted, a
ROW-DELETE event occurs. Since the record has not yet been
deleted, the record remains in the temp-table buffer and the code can access its
values. |
|
ROW-UPDATE |
Immediately before the temp-table record is updated, a
ROW-UPDATE event occurs. |
Log all changes to a table. |
Use a change event handler in the client
In the following example, a ROW-UPDATE event
handler for the ttOrderLine temp-table buffer is
used to limit the maximum discount an order line can have to 20%. This event
handler, named DiscountTooHigh, is an internal
procedure of the external procedure library file that is used in the client.
|
The following is the client code that updates the dataset. To use the event
handler, the client code first runs the external procedure as PERSISTENT and then associates the ROW-UPDATE event handler, DiscountTooHigh, with the ttOrderLine
temp-table buffer. When the client updates data in the ttOrderLine record, it does so by calling the SetDiscount internal procedure. In the SetDiscount procedure, a transaction block is required around the code
that updates the temp-table. As with database transactions, scope ABL transactions
to be as small as possible for good performance. When SetDiscount updates the record, the DiscountTooHigh event handler runs.
|