SQL Guide : solidDB® SQL statements : CREATE TRIGGER
  
CREATE TRIGGER
CREATE TRIGGER trigger_name ON table_name time_of_operation
   triggering_event [REFERENCING column_reference]
   BEGIN trigger_body END
where:
trigger_name        ::= literal
table
_name           ::= literal
time
_of_operation    ::= BEFORE | AFTER
triggering_event     ::= INSERT | UPDATE | DELETE
column_reference     ::= {OLD | NEW} column_name [AS] col_identifier
                         [, REFERENCING column_reference ]
trigger_body ::=
                         [declare_statement;... ]
                         [trigger_statement;...]
old_column_name      ::= literal
new
_column_name      ::= literal
col
_identifier       ::= literal
Usage
A trigger provides a mechanism for executing a series of SQL statements when a particular action (an INSERT, UPDATE, or DELETE) occurs. The body of the trigger contains the SQL statement(s) that the user wants to execute. The body of the trigger is written using the stored procedure language (see CREATE PROCEDURE).
You can create one or more triggers on a table, with each trigger defined to activate on a specific INSERT, UPDATE, or DELETE command. When a user modifies data within the table, the trigger that corresponds to the command is activated.
You can only use inline SQL or stored procedures with triggers. If you use a stored procedure in the trigger, the procedure must be created with the CREATE PROCEDURE command. A procedure invoked from a trigger body can invoke other triggers.
To create a trigger, you must be a DBA or owner of the table on which the trigger is being defined.
Triggers are created with the CREATE TRIGGER statement and dropped from the system catalog with the DROP TRIGGER statement. Triggers can also be disabled with the ALTER TRIGGER statement.
Example
"CREATE TRIGGER TRIGGER_BI ON TRIGGER_TEST
   BEFORE INSERT
   REFERENCING NEW BI AS NEW_BI
BEGIN
   EXEC SQL PREPARE BI INSERT INTO TRIGGER_OUTPUT VALUES (
    'BI', TRIG_NAME(0), TRIG_SCHEMA(0));
   EXEC SQL EXECUTE BI;
   SET NEW_BI = 'TRIGGER_BI';
END";
Related reference
ALTER TRIGGER
DROP TRIGGER
Related information
See
trigger_name
BEFORE | AFTER clause
INSERT | UPDATE | DELETE clause
table_name
trigger_body
REFERENCING clause
Triggers usage notes and restrictions
See also
solidDB® SQL statements