FirebirdSQL logo

Semantics

  1. BEFORE triggers are fired before changes to the system tables.AFTER triggers are fired after system table changes.

    Important
    Important Rule

    The event type [BEFORE | AFTER] of a DDL trigger cannot be changed.

  2. When a DDL statement fires a trigger that raises an exception (BEFORE or AFTER, intentionally or unintentionally) the statement will not be committed.That is, exceptions can be used to ensure that a DDL operation will fail if the conditions are not precisely as intended.

  3. DDL trigger actions are executed only when committing the transaction in which the affected DDL command runs.Never overlook the fact that what is possible to do in an AFTER trigger is exactly what is possible to do after a DDL command without autocommit.You cannot, for example, create a table and then use it in the trigger.

  4. With “CREATE OR ALTER” statements, a trigger is fired one time at the CREATE event or the ALTER event, according to the previous existence of the object.With RECREATE statements, a trigger is fired for the DROP event if the object exists, and for the CREATE event.

  5. ALTER and DROP events are generally not fired when the object name does not exist.For the exception, see point 6.

  6. The exception to rule 5 is that BEFORE ALTER/DROP USER triggers fire even when the username does not exist.This is because, underneath, these commands perform DML on the security database, and the verification is not done before the command on it is run.This is likely to be different with embedded users, so do not write code that depends on this.

  7. If an exception is raised after the DDL command starts its execution and before AFTER triggers are fired, AFTER triggers will not be fired.

  8. Packaged procedures and functions do not fire individual {CREATE | ALTER | DROP} {PROCEDURE | FUNCTION} triggers.

The DDL_TRIGGER Context Namespace

When a DDL trigger is running, the DDL_TRIGGER namespace is available for use with RDB$GET_CONTEXT.This namespace contains information on the currently firing trigger.