Neoview SQL Reference Manual (R2.4)

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. See “Triggers” (page 291).
CREATE TRIGGER trigger-name
{BEFORE | AFTER}
{INSERT | DELETE | UPDATE [OF (columns)]}
ON table-name
[REFERENCING old-new-alias-list ]
[FOR EACH {ROW | STATEMENT}]
[ WHEN (search-condition)]
triggered-SQL-statement;
columns is:
column-name, columns | column-name
old-new-alias-list is:
old-new-alias, old-new-alias | old-new-alias
old-new-alias is :
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 “Database Object Names” (page 228).
column-name
specifies the name of the new column that correlates to the row to be modified. See “Database
Object Names” (page 228).
table-name
specifies the name of the trigger subject table. See “Database Object Names” (page 228).
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.
CREATE TRIGGER Statement 93