Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / May 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
aj - 24 May 2006 16:03 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.