Creating triggers v14
The CREATE TRIGGER
command defines and names a trigger that's stored in the database.
Name
CREATE TRIGGER
— Define a simple trigger.
Synopsis
CREATE [ OR REPLACE ] TRIGGER <name> { BEFORE | AFTER | INSTEAD OF } { INSERT | UPDATE | DELETE | TRUNCATE } [ OR { INSERT | UPDATE | DELETE | TRUNCATE } ] [, ...] ON <table> [ REFERENCING { OLD AS <old> | NEW AS <new> } ...] [ FOR EACH ROW ] [ WHEN <condition> ] [ DECLARE [ PRAGMA AUTONOMOUS_TRANSACTION; ] <declaration>; [, ...] ] BEGIN <statement>; [, ...] [ EXCEPTION { WHEN <exception> [ OR <exception> ] [...] THEN <statement>; [, ...] } [, ...] ] END
Name
CREATE TRIGGER
— Define a compound trigger.
Synopsis
CREATE [ OR REPLACE ] TRIGGER <name> FOR { INSERT | UPDATE | DELETE | TRUNCATE } [ OR { INSERT | UPDATE | DELETE | TRUNCATE } ] [, ...] ON <table> [ REFERENCING { OLD AS <old> | NEW AS <new>. } ...] [ WHEN <condition> ] COMPOUND TRIGGER [ <private_declaration>; ] ... [ <procedure_or_function_definition> ] ... <compound_trigger_definition> END
Where private_declaration
is an identifier of a private variable that can be accessed by any procedure or function. There can be zero, one, or more private variables. private_declaration
can be any of the following:
- Variable declaration
- Record declaration
- Collection declaration
REF CURSOR
and cursor variable declarationTYPE
definitions for records, collections, andREF CURSOR
- Exception
- Object variable declaration
Where procedure_or_function_definition :=
procedure_definition | function_definition
Where procedure_definition :=