602SQL Documentation Index  

Sequence of Actions and Checks when Executing Statements

Execution of the UPDATE, INSERT or DELETE statements may cause simultaneous execution of triggers, integrity constrains checks and execution of active referential integrity actions. It's necessary to know the order of these actions.

When are the Integrity Constraints Checked?

Server may control the integrity constraints compliance either on the statement termination or on the transaction finish. The exact time of integrity constraint evaluation is set by the INITIALLY IMMEDIATE or INITIALLY DEFERRED clauses.

Sequence of Actions and Checks when Executing Statements

Execution of a statement is always like this:

  1. BEFORE trigger FOR EACH STATEMENT
  2. processing of all records in the statement
  3. AFTER trigger FOR EACH STATEMENT

This order of actions is executed for each record affected by the statement:

  1. BEFORE trigger FOR EACH ROW
  2. execution of data change:
  3. indexes adjustment, so they correspond with the new values
  4. UNIQUE check
  5. active referential integrity actions (cascade change or delete and check)
  6. AFTER trigger FOR EACH ROW
  7. check of the IMMEDIATE integrity: internal CHECK rules + test for superior records existence for changed records in the inferior tables in the referential integrity.