From InterBase
Jump to: navigation, search

Go Up to Creating Triggers

The syntax of CREATE TRIGGER is:

CREATE TRIGGER name FOR {table | view}
 [POSITION number]
AS <trigger_body>
<trigger_body>; = [<variable_declaration_list>]
<variable_declaration_list> = DECLARE VARIABLE variable data_type;
[DECLARE VARIABLE variable data_type; ]
<block> =
 [<compound_statement> ]
<compound_statement> = <block> | statement;
Arguments of the CREATE TRIGGER statement
Argument Description


Name of the trigger. The name must be unique in the database.


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:

ACTIVE: (Default). Trigger takes effect.

INACTIVE: Trigger does not take effect.


Required. Specifies whether the trigger fires:

BEFORE: Before associated operation.

AFTER: After associated operation.

Associated operations are DELETE, INSERT, or UPDATE.


Specifies the table operation that causes the trigger to fire.

POSITION <number>

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.

DECLARE VARIABLE <var> <data_type>

Declares local variables used only in the trigger. Each declaration must be preceded by DECLARE VARIABLE and followed by a semicolon (;).

<var>: Local variable name, unique in the trigger.

<data_type>: The data type of the local variable.


Any single statement in InterBase procedure and trigger language. Each statement except BEGIN and END must be followed by a semicolon (;).


Terminator defined by the SET TERM statement which signifies the end of the trigger body; deprecated in InterBase 7.0. [No longer needed]

Advance To: