View Single Post
  #4 (permalink)  
Old 08-20-03, 02:50
sathyaram_s sathyaram_s is online now
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,354
Re: Simple trigger help needed, Update who & when

Are you sure the trigger is valid ?

Check the VALID column in SYSCAT.TRIGGERS

Sathyaram


Quote:
Originally posted by janrune
Hi...
I have a simple question for one who is experienced...
In all our tables we have the two fields Edit_Who and Edit_When:
KL_Edit_Who VarChar(30) DEFAULT USER,
KL_Edit_When TIMESTAMP DEFAULT CURRENT TIMESTAMP,

In order to get those updated on each update we have to revert to triggers.
So I wrote two versions neither works...
CREATE TRIGGER KL_Key_LastGen_Upd
AFTER INSERT ON DBO.KL_Key_LastGen
FOR EACH ROW MODE DB2SQL
UPDATE DBO.KL_Key_LastGen SET KL_Edit_Who = USER, KL_Edit_When = CURRENT TIMESTAMP

CREATE TRIGGER KL_Key_LastGen_Upd
AFTER INSERT ON DBO.KL_Key_LastGen
REFERENCING NEW_TABLE AS NEWEMPS
FOR EACH STATEMENT MODE DB2SQL
UPDATE DBO.KL_Key_LastGen K SET KL_Edit_Who = USER, KL_Edit_When = CURRENT TIMESTAMP
WHERE KL_Table_Key IN( SELECT NEWEMPS.KL_Table_Key FROM NEWEMPS)

Anyone care to shed some light on my errors ???
Thanks
JR
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote