dbTalk Databases Forums  

trigger transition tables

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss trigger transition tables in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
alederer
 
Posts: n/a

Default trigger transition tables - 08-11-2003 , 07:31 AM






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


Reply With Quote
  #2  
Old   
Serge Rielau
 
Posts: n/a

Default Re: trigger transition tables - 08-14-2003 , 10:30 AM






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



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.