


An SQL-PL module is declared to be a trigger by the keyword TRIGGER. In the database, it is only activated by using the menu item 'The Menu Item 'Object'' (see The Workbench chapter, sections The Menu Item 'Object' or Commands, TCREATE. The following specifications are made in this command:
- the name of the trigger as database object.
- the name of the table to which the trigger is bound.
- the SQL statements after which the trigger is to be called. At present, these are INSERT, UPDATE, and DELETE. The call of the UPDATE trigger can be restricted to the updating of certain columns.
- optionally an additional condition that restricts the call of the trigger to certain rows of the table.
The parameters of a trigger must be declared according to mode and type. For each parameter, a column with the same name and the same type must exist in the table for which the trigger is created. The prefixes "old." and "new." before the parameter name allow the old or new column value to be addressed in UPDATE triggers.

Additional Predicates in Triggers
Apart from the predicates already familiar, the following additional predicates are available for the formulation of triggers:
- FIRSTCALL is true if the trigger was called by a single command or by the first row of a bulk command.
- LASTCALL is true if the trigger was called by a single command or by the last row of a bulk command.
- INSERTING, UPDATING or DELETING are true if the trigger was called by a corresponding SQL statement.
The usage of these predicates only makes sense within a trigger. In any other case they are not true.
Syntax:



