Back
Home
Up
Next

Dispatching of events at will.

    Events are an artifact for communication in Object Oriented languages like Delphi. Whereas Interbase's Trigger and Procedure Language is procedural and not OO, it has events to communicate with the client applications.

Events in IB don't carry additional information. This means you know that an event occurred because an event with the name you were waiting for was posted.

Posting an event is a feature only available in triggers and stored procedures with the syntax
POST_EVENT 'event_name' | col

For example, POST_EVENT 'new_order'
will send a notification to applications that registered interest in knowing when "new_order" happens. This form can be used by both trigger and procedures. Using the alternative syntax

POST_EVENT NEW.COMPANY
means a trigger is posting an event whose message is the new value of the field "company" in the associated table. Of course, this assumes the applications know the possible values of this field to be able to register interest in some values. All values are converted to text.

The client application, on the other side, uses EVENT INIT and EVENT WAIT to start monitoring the occurrence of events. Although this may be done though the API, there are different high level components for Delphi to deal with them without knowing these details, see the Useful Links page, for example.

You must remember this behavior: the event manager keeps track of events of interest. At commit time, when an event occurs, the event manager notifies interested applications. In other words, triggers and stored procedures may post multiple events but only when the controlling application decided to commit, the applications will receive the event. If the transaction is rolled back, then events that originated inside it will be discarded.

 

This page was last updated on 2000-05-26 04:28:46