CREATE TRIGGER Syntax
Go Up to Creating Triggers
The syntax of CREATE TRIGGER
is:
CREATE TRIGGER name FOR {table | view} [ACTIVE | INACTIVE] {BEFORE | AFTER} {DELETE | INSERT | UPDATE} [POSITION number] AS <trigger_body> <trigger_body> = [<variable_declaration_list>] <block> <variable_declaration_list> = DECLARE VARIABLE variable datatype; [DECLARE VARIABLE variable datatype; …] <block> = BEGIN <compound_statement> [<compound_statement> …] END <compound_statement> = <block> | statement;
Argument | Description |
---|---|
<name> |
Name of the trigger. The name must be unique in the database. |
<table> |
Name of the table or view that causes the trigger to fire when the specified operation occurs on the table or view. |
|
Optional. Specifies trigger action at transaction end:
|
|
Required. Specifies whether the trigger fires:
Associated operations are |
|
Specifies the table operation that causes the trigger to fire. |
|
Specifies firing order for triggers before the same action or after the same action. <number> must be an integer between 0 and 32,767, inclusive. Lower-number triggers fire first. Default: 0 = first trigger to fire. Triggers for a table need not be consecutive. Triggers on the same action with the same position number will fire in alphabetic order by name. |
|
Declares local variables used only in the trigger. Each declaration must be preceded by <var>: Local variable name, unique in the trigger. <datatype>: The data type of the local variable. |
<statement> |
Any single statement in InterBase procedure and trigger language. Each statement except |
<terminator> |
Terminator defined by the |