Trigger definitionsTrigger definitions mk Sun, 03/28/2010 - 23:32
Triggers are a convenient programming abstraction. They are activated at transaction commit based on updates to the base tables.
trigger_def: CREATE [ OR REPLACE ] TRIGGER qname trigger_action_time trigger_event ON ident opt_referencing_list triggered_action
trigger_action_time: BEFORE | AFTER
trigger_event: INSERT | DELETE | TRUNCATE | UPDATE | UPDATE OF ident ','...
opt_referencing_list: [ REFERENCING old_or_new_values_alias ... ]
opt_for_each: /* default is for each statement */ | FOR EACH ROW | FOR EACH STATEMENT
Example The following example provides a glimpse of their functionality:
create table t1 (id int, name varchar(1024));
--test FOR EACH STATEMENT (default one)
insert into t1 values(10, 'monetdb');
insert into t1 values(20, 'monet');
create trigger test5
after update on t1 referencing new row as new_row
for each statement
when (new_row.id > 0) insert into t1 values(4, 'update_when_statement_true');
All trigger definitions are considered together at the transaction commit. There is no a priori defined order in which they run. Each may in turn activate new triggers, but each trigger definition is also executed only once per transaction commit.