Programming with Database Events

From InterBase
Jump to: navigation, search

Go Up to Developer's Guide


Use the TIBEvents component in your IBX-based application to register interest in and asynchronously handle InterBase server events. The InterBase event mechanism enables applications to respond to action and database changes made by other, concurrently running applications without the need for those applications to communicate directly with each other, and without incurring the expense of CPU time required for period polling to determine if an event has occurred.

Use the TIBEvents component in your application to register an event (or a list of events) with the event manager. The event manager maintains a list of events posted to it by triggers and stored procedures. It also maintains a list of applications that have registered an interest in events. Each time a new event is posted to it, the event manager notifies interested applications that the event has occurred.

To use TIBEvents in your application:

  1. Create a trigger or stored procedure on the InterBase server which will post an event.
  2. Add a TIBDatabase and a TIBEvents component to your form.
  3. Add the events to the Events list and register them with the event manager.
  4. Write an OnEventAlert event handler for each event.

Events are passed by triggers or stored procedures only when the transaction under which they occur is posted. Also, InterBase consolidates events before posting them. For example, if an InterBase trigger posts 20 x STOCK_LOW events within a transaction, when the transaction is committed these will be consolidated into a single STOCK_LOW event, and the client will only receive one event notification.

For more information on events, refer to Working with Events in the Embedded SQL Guide.

Topics