Types of triggers v14
EDB Postgres Advanced Server supports row-level and statement-level triggers. A row-level trigger fires once for each row that's affected by a triggering event. For example, suppose deletion is defined as a triggering event on a table, and a single DELETE
command is issued that deletes five rows from the table. In this case, the trigger fires five times, once for each row.
A statement-level trigger fires once per triggering statement, regardless of the number of rows affected by the triggering event. In the previous example of a single DELETE
command deleting five rows, a statement-level trigger fires only once.
You can define the sequence of actions regarding whether the trigger code block executes before or after the triggering statement for statement-level triggers. For row-level triggers, you can define whether the trigger code block executes before or after each row is affected by the triggering statement.
In a before row-level trigger, the trigger code block executes before the triggering action is carried out on each affected row. In a before statement-level trigger, the trigger code block executes before the action of the triggering statement is carried out.
In an after row-level trigger, the trigger code block executes after the triggering action is carried out on each affected row. In an after statement-level trigger, the trigger code block executes after the action of the triggering statement is carried out.
In a compound trigger, you can define a statement-level and a row-level trigger in a single trigger and fire it at more than one timing point. For details, see Compound triggers.