dbTalk Databases Forums  

Can I dynamically reference the table and/or column name in a triggerbody? Special Register?

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


Discuss Can I dynamically reference the table and/or column name in a triggerbody? Special Register? in the comp.databases.ibm-db2 forum.



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

Default Can I dynamically reference the table and/or column name in a triggerbody? Special Register? - 05-24-2006 , 10:03 AM






DB2 LUW latest & greatest 8.2 FP11

Is there any way to dynamically reference the table and/or column name
in a trigger body, perhaps w/ a special register or something?

SP WRITE_AT() is passed: table,PK,operation,user,column,oldval,newval

So instead of:
CREATE TRIGGER UPD_ACCT_NAME
AFTER update of name on account
referencing new as new
referencing old as old
FOR EACH ROW MODE DB2SQL
BEGIN ATOMIC
CALL WRITE_AT('account',old.account_id,'U',USER,
'name',old.name,new.name) ;
END !

I want something along the lines of:
CREATE TRIGGER UPD_ACCT_NAME
AFTER update of name on account
referencing new as new
referencing old as old
FOR EACH ROW MODE DB2SQL
BEGIN ATOMIC
CALL WRITE_AT(TABLE,old.account_id,'U',USER,
COLUMN,old.name,new.name) ;
END !

TIA

aj

Reply With Quote
  #2  
Old   
Mehmet Baserdem
 
Posts: n/a

Default Re: Can I dynamically reference the table and/or column name in a trigger body? Special Register? - 05-24-2006 , 01:46 PM






AJ,

Since you already referenced it, I think you should be able to replace
the TABLE parameter with "new" (w/o quotes) in your WRITE_AT SP
call.

FYI:
To avoid confusion, I would reference like that
CREATE TRIGGER UPD_ACCT_NAME
AFTER update of name on account
REFERENCING new as n ..................

and use it like this
CALL WRITE_AT(n,............

But I am clueless about replacement for COLUMN.

Regards,

Mehmet Baserdem


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.