Mimer SQL Programmer's Manual TOC PREV NEXT INDEX

Mimer Developer Site

www.mimer.com/developer


Creating a Trigger


A trigger is created by using the CREATE TRIGGER statement, see the Mimer SQL Reference Manual.

Examples:
 CREATE TRIGGER LOG_DATA BEFORE DELETE ON BOOK_GUEST
 BEGIN ATOMIC
   ...
 END;
 
 CREATE TRIGGER LOG_DATA AFTER INSERT ON BOOK_GUEST
 REFERENCING NEW TABLE AS GUESTS
 BEGIN ATOMIC
   DECLARE GUEST_CURSOR CURSOR FOR SELECT * FROM GUESTS;
   ...
 END;
 
 CREATE TRIGGER JOIN_UPDATE INSTEAD OF UPDATE ON INVOICE
 REFERENCING OLD TABLE AS OLD_INVOICE
             NEW TABLE AS NEW_INVOICE
  BEGIN ATOMIC
    DECLARE OLD_INVOICE CURSOR FOR SELECT * FROM OLD_INVOICE;
    DECLARE NEW_INVOICE CURSOR FOR SELECT * FROM NEW_INVOICE;
    ...
 END;
 

A trigger is created on a named table or view and the trigger must be created in the schema to which the table or view belongs. If the trigger is created on a base table, the table must be stored in a databank with the TRANS or LOG option.

The trigger name must follow the rules for naming private database objects, see the Mimer SQL Reference Manual, and the name must be unique within the schema in which the trigger is created.

It is possible to create any number of triggers on a named table, each of which may have the same trigger time, see Trigger Time, and trigger event, see Trigger Event, specified.

If two or more triggers exist on the same table with the same trigger time and trigger event, they will be executed in an order determined by their internal creation timestamp.

Note: When triggers are created using BSQL, the create statement must be delimited by the "@" character.


Upright Database Technology AB
Voice: +46 18 780 92 00
Fax: +46 18 780 92 40
dbtechnology@upright.se
Mimer SQL Programmer's Manual TOC PREV NEXT INDEX