Documentation
 
 
 

CREATE TRIGGER

Name

CREATE TRIGGER -- define a new trigger

Synopsis

CREATE  OR REPLACE  TRIGGER name
{ BEFORE | AFTER } { INSERT | UPDATE | DELETE }  OR { INSERT | UPDATE | DELETE } ... ON
table
 FOR EACH ROW 
DECLARE
    declarations 
BEGIN
    statements
END;

Description

The CREATE TRIGGER command defines and names a trigger that will be stored in the database.

Parameters

name

The name of the trigger to be created. This must be distinct from the name of any other trigger for the same table.

OR REPLACE

If specified and a trigger with the same name already exists then the new trigger replaces the existing one.

BEFORE
AFTER

This determines whether the trigger is invoked before or after the event.

event

The values can be one of INSERT, UPDATE, or DELETE. It specifies the event that will fire the trigger. Multiple events can be specified by using the keyword, OR, between event names.

table

The table for which the trigger will be fired.

FOR EACH ROW

This specifies the trigger should be fired once for each row affected by the triggering event. If not specified, the trigger is defined as a statement-level trigger.

declarations

Can be variable, cursor or type declarations.

statements

Statements are SPL program statements

Notes

The BEGIN - END block may contain an EXCEPTION.

Examples

Example 1: Section 15.6.1

Example 2: Section 15.6.2

Example 3: Section 15.6.3

Example 4: Section 15.6.4

See Also

DROP TRIGGER
 
 ©2004-2007 EnterpriseDB All Rights Reserved