Monday, September 26, 2011

Timestamp fun

With Version 9 we got the ability to define a timestamp column that will automatically updated when some other column on the row is updated (kind of like a trigger).

REC_UPDT_TS TIMESTAMP NOT NULL
  GENERATED BY DEFAULT
  FOR EACH ROW ON UPDATE AS ROW CHANGE TIMESTAMP

However, there may be circumstances in which we don't want to have this column automatically updated. In those cases, you can code the SQL as follows;

UPDATE CREATOR.TABLE
SET column1 = 'some value'
    , REC_UPDT_TS = REC_UPDT_TS
WHERE column2 = 'another value'

No comments:

Post a Comment