CREATE TRIGGER Statement
•
"Syntax Description of CREATE TRIGGER"
•
"Considerations for CREATE TRIGGER"
•
"Examples of CREATE TRIGGER"
The CREATE TRIGGER statement is used to create triggers on SQL tables. A trigger is a
mechanism that sets up the database system to perform certain actions automatically in response
to the occurrence of specified events.
CREATE TRIGGER trigger-name
{BEFORE | AFTER}
{INSERT | DELETE | UPDATE [OF (columns)]}
ON table-name
[REFERENCING old-new-alias-list ]
[FOR EACH
columns is:
column-name, columns | column-name
old-new-alias-list is:
old-new-alias, old-new-alias | old-new-alias
old-new-alias
OLD [ROW] [AS] correlation-name
NEW [ROW] [AS] correlation-name
OLD [TABLE] [AS] table-alias
NEW [TABLE] [AS] table-alias
triggered-SQL-statement is:
searched-update-statement
searched-delete-statement
atomic-compound-statement
CALL-statement
insert-statement |
signal-statement |
set-new-statement
atomic-compound-statement is:
BEGIN ATOMIC
{triggered-SQL-statement | IF-statement}...
END;
signal-statement is:
SIGNAL SQLSTATE quoted-sqlstate (quoted-string-expr);
set-new-statement is:
SET correlation-name.column-name = value-expression
Syntax Description of CREATE TRIGGER
trigger-name
specifies the name of the trigger to create. See
column-name
specifies the name of the new column that correlates to the row to be modified. See
Object Names" (page
table-name
specifies the name of the trigger subject table. See
FOR EACH { ROW | STATEMENT }
specifies whether the trigger is based on a row or a statement. If you do not specify this clause,
the default is ROW for a BEFORE trigger and STATEMENT for an AFTER trigger.
{ROW | STATEMENT}]
[ WHEN (search-condition)]
triggered-SQL-statement;
is :
|
|
|
|
196).
|
|
|
"Database Object Names" (page
"Database Object Names" (page
196).
"Database
196).
CREATE TRIGGER Statement
81