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
Mehmet Baserdem - 24 May 2006 19:46 GMT
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