Firebird Documentation IndexFirebird ODBC/JDBC Driver Manual → Firebird Events
Firebird Home Firebird Home Prev: Usage with ClarionFirebird Documentation IndexUp: Firebird ODBC/JDBC Driver ManualNext: Priming the Driver to Listen for Events

Chapter 6: Firebird Events

Table of Contents

Priming the Driver to Listen for Events

To illustrate the use of Firebird events with the ODBC/JDBC driver, we use the example database, employee.fdb and work with the SALES table. This table has an AFTER INSERT trigger POST_NEW_ORDER that contains the statement POST_EVENT 'new_order';. Its effect will be to signal a listener on the client side when a new record is committed into SALES.

Let us suppose that the table has also a BEFORE UPDATE trigger that posts an event 'change_order' in subsequent operations when the field ORDER_STATUS is changed.

Tip

The trigger BEFORE UPDATE does not exist: this scenario is just for illustration purposes, but you could create it if you like:

CREATE OR ALTER TRIGGER BI_SALES FOR SALES
ACTIVE BEFORE UPDATE
AS BEGIN
  IF (NEW.ORDER_STATUS = 'new') THEN
  BEGIN
     NEW.ORDER_STATUS = 'open';
     POST_EVENT 'change_order';
  END
END
        

For our demo, we need to insert a new record into SALES. The field ORDER_STATUS on the newly-inserted record contains the default value 'new'. After it commits, posting the event 'new_order', we want to go back and change something in the new record. When we do so, our BEFORE UPDATE trigger, BI_SALES will check whether the value of ORDER_STATUS is still 'new' and, if so, it will change it to 'open' and post the event 'change_order'.

Note

We are not really interested in how inserting and changing the record affects the database state. The idea here is to show how to prime the driver to manage listening for multiple events.

Prev: Usage with ClarionFirebird Documentation IndexUp: Firebird ODBC/JDBC Driver ManualNext: Priming the Driver to Listen for Events
Firebird Documentation IndexFirebird ODBC/JDBC Driver Manual → Firebird Events