Defining a Trigger Event and Action
This syntax defines the event and action of a trigger
on a table or on a view.
Trigger on a Table |--+-+-DELETE---------------------+--ON--table--| DELETE and SELECT Clauses |--+--| | '-SELECT--+----------------+-' | | | .-,------. | | | | V | | | | '-OF----column-+-' | +-UPDATE--+----------------+--ON--table--| UPDATE Clause |------------------+ | | .-,------. | | | | V | | | | '-OF----column-+-' | | (1) (2) | '-INSERT--ON--table--+-| NEW Declaration |------| Correlated Action |-----+-' | (3) | '-| Action Clause |----------------------------------' DELETE and SELECT Clauses (3) |--+-| Action Clause |----------------------------------+-------| | (4) (2) | '-| OLD Declaration |------| Correlated Action |-----' UPDATE Clause (3) |--+-| Action Clause |---------------------------------------------------------------+--| | (4) (2) | '-| OLD Declaration |------+-------------------------+--| Correlated Action |-----' | (1) | '-| NEW Declaration |-----' Trigger on a View |--+-INSERT ON--view--+--------------------------------------+--------------------------------+--> | '-REFERENCING NEW--+----+--correlation-' | | '-AS-' | +-DELETE ON--view--+---------------------------------------+-------------------------------+ | '-REFERENCING--OLD--+----+--correlation-' | | '-AS-' | '-UPDATE ON--view--+---------------------------------------------------------------------+-' +-REFERENCING--OLD--+----+--correlation--+--------------------------+-+ | '-AS-' '-NEW--+----+--correlation-' | | '-AS-' | '-REFERENCING--NEW--+----+--correlation--+--------------------------+-' '-AS-' '-OLD--+----+--correlation-' '-AS-' (5) >--FOR EACH ROW--| INSTEAD OF Triggered Action |----------------|
Notes:
- See REFERENCING Clause for Insert triggers
- See Correlated Table Action
- See Action Clause
- See REFERENCING Clause for Update
- See INSTEAD OF Triggers on Views
Element | Description | Restrictions | Syntax |
---|---|---|---|
column | The name of a column in the triggering table | Must exist | Identifier |
correlation | Name that you declare here to qualify an old or new column value (as correlation.column) in a triggered action | Must be unique in this trigger | Identifier |
table, view | Name or synonym of the triggering table or view. The table or view can include an owner. qualifier. | Must exist in the current database | Identifier |
The left-hand portion of the main diagram (including the table or view) defines the trigger event (sometimes called the triggering event). The rest of the diagram declares correlation names and defines the trigger action (sometimes called the triggered action).
For the syntax to specify the triggered action of triggers on tables, see Action Clause and Correlated Table Action.
For the syntax to specify the triggered action of INSTEAD OF triggers on views, see The Action Clause of INSTEAD OF Triggers.