Chapter 9. SQL Language 283
returning int;
LET n.col1 = n.col1 * 1.1 ; -- increment the inserted value 10%
end procedure;
-- use the proc1 inside for each row trigger.
create trigger ins_trig_tab1 INSERT on tab1 referencing new as post
for each row(execute procedure proc1() with trigger references);
-- use the proc1 inside for each row trigger.
create trigger ins_trig_tab2 INSERT on tab2 referencing new as n
for each row (execute procedure proc2() with trigger references);
insert into tab1 values (111,222);
The above statement will execute ins_trigger trig_tab1 and therefore will
execute procedure proc1(). The procedure will increment the value of col1
by 1. So, the value inserted will be (112, 222).
insert into tab2 values (100);
The above statement will execute ins_trigger trig_tab2 and therefore will
execute procedure proc2(). The procedure will increment the value of col1
by 10%. So, the value inserted into tab2 will be 110.
A procedures created with a REFERENCING clause can only be called from a
FOR EACH ROW trigger and has to be executed using the WITH TRIGGER
REFERENCES modifier to execute procedure statement. IDS raises an error for
all other forms of invocation.
9.13 Index self-join access method
Traditionally, an index scan allows you to scan a single range (based on the
start/stop key) of an index. The
index self-join access method lets you scan many
mini-ranges instead of a large single range, based on filters on non-leading keys
of an index.
The index self-join is a new type of index scan where the table is logically joined
to itself, such that for each unique combination of the leading key columns of an
index, additional filters on non-leading key columns of the index are used to
perform a more efficient mini-index scan. Results from multiple mini-index scans
are then combined to generate the result set of the query.