Phase and Event - Firebird

Table summarizes the eight kinds of trigger module.

Phase/Event Combinations for Trigger Modules

Phase/Event Combinations for Trigger Modules

Phase/Event Combinations for Trigger Modules

Sequence

Firebird allows multiple trigger modules for any phase/event combination. There is probably some practical limit, but it is safe to say you can create as many as you need, using whole numbers between 0 and 32,767. The default is sequence number ("POSITION") zero. It is good science to set an order of execution by numbering the triggers, but explicit sequencing is optional. If sequence numbers are present, the triggers will be executed in ascending order. Numbers don’t have to be unique and the sequence can have gaps.

Suites of triggers for a phase/event with the default POSITION 0 will be executed in the alphabetical order of their names. The same can be expected if you have groupings of triggers sharing the same non-zero sequence number.

The following example demonstrates how four update triggers for the ACCOUNT table would be fired:

CREATE TRIGGER BU_ACCOUNT5 FOR ACCOUNT
ACTIVE BEFORE UPDATE POSITION 5 AS ...
CREATE TRIGGER BU_ACCOUNT0 FOR ACCOUNT
ACTIVE BEFORE UPDATE POSITION 0 AS ...
CREATE TRIGGER AU_ACCOUNT5 FOR ACCOUNT
ACTIVE AFTER UPDATE POSITION 5 AS ...
CREATE TRIGGER AU_ACCOUNT3 FOR ACCOUNT
ACTIVE AFTER UPDATE POSITION 3 AS ...

Someone updates some rows in ACCOUNTS:

UPDATE ACCOUNT
SET C ='CANCELED'
WHEREC2 = 5;

This is the sequence of events on each affected row:

  1. Trigger BU_ACCOUNT0 fires.
  2. Trigger BU_ACCOUNT5 fires.
  3. The new record version is written to disk.
  4. Trigger AU_ACCOUNT3 fires.
  5. Trigger AU_ACCOUNT5 fires.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Firebird Topics