ggnanaraj, rahul_s80 suggestion is nice one - creating trigger is one of solution.
Sample (Trigger fires up before update of column col1):
Code:
CREATE TABLE DB2ADMIN.TAB1 (
COL1 INTEGER ,
COL2 TIMESTAMP DEFAULT CURRENT TIMESTAMP)@
INSERT INTO DB2ADMIN.TAB1 VALUES (1,CURRENT TIMESTAMP) @
INSERT INTO DB2ADMIN.TAB1 VALUES (2,CURRENT TIMESTAMP) @
CREATE TRIGGER DB2ADMIN.TRIG
BEFORE UPDATE OF COL1 ON DB2ADMIN.TAB1
REFERENCING NEW AS NEW
FOR EACH ROW
BEGIN ATOMIC
SET NEW.COL2 = CURRENT TIMESTAMP;
END @
Save commands in file.sql and execute above commands by:
Code:
db2 -td@ -f file.sql
Note: default definition at col2 column is to get the timestamp executed by insert statements.
See data before update:
Code:
SELECT * FROM DB2ADMIN.TAB1
Execute the following SQL to see the change:
Code:
UPDATE DB2ADMIN.TAB1 SET COL1=100 WHERE COL1=2
Check data one more time:
Code:
SELECT * FROM DB2ADMIN.TAB1
Have you noticed the timestamp has only changed in col1=100 row.
Hope this helps,
Grofaty