Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

trigger transition tables

0 views
Skip to first unread message

alederer

unread,
Aug 11, 2003, 8:31:55 AM8/11/03
to
hallo!

i have the following questing:

is it possible to reference the trigger transition tables (OLD_TABLE,
NEW_TABLE) inside a procedure which is called from a statement trigger?

e.g. i need a trigger
create trigger trig_u_a after update on a
referencing NEW_TABLE as new OLD_TABLE as old
for each statement
mode db2sql
begin atomic
values(proc_u_a(new, old));
end

the stored procedure for example should look like

create procedure proc_u_a(IN new tabletype, IN old tabletype)
language sql
...
insert into tab_c select new.col1, old.col1 ... from new, old
...


is this possible?

thanks
andreas lederer

Serge Rielau

unread,
Aug 14, 2003, 11:30:06 AM8/14/03
to
On DB2 z/Series you can pass the transition table via a table-locator.
DB2 i/Series I don't know.
DB2 for LUW you can't do it directly.
Here is a trick:

CREATE SEQUENCE uid;
CREATE TABLE T1_NT AS (SELECT 1 AS id, T1.* FROM T1) DEFINITION ONLY;

CREATE TRIGGER ... AFTER .. ON T1 REFERENCING NEW_TABLE AS nt ....
BEGIN ATOMIC
INSERT INTO T1_NT SELECT NEXT VALUE FOR uid, NT.* FROM Nt;
VALUES (proc(PREVIOUS VALUE FOR uid));
DELETE FROM T1_NT WHERE id = PREVIOUS VALUE FOR uid;
END


0 new messages