In my table I’ve a column MODIFIED with type TIMESTAMP.
I want to update this column automatically when the row is updated
I can use this for a new column
alter table my_table add column last_updated timestamp not null
generated by default for each row on update as row change timestamp
But I can’t use this to edit the existing column to do the updating automatically
alter table my_table alter column modified set data type timestamp
not null generated by default for each row on update as row change timestamp
Am I using the alter correctly?
the error message is
Error: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=alter table my_table alter column modified;BEGIN-OF-STATEMENT;<values>, DRIVER=3.50.152
SQLState: 42601
ErrorCode: -104
Found an article here
http://ibmsystemsmag.blogs.com/db2utor/2008/01/automate-row-ch.html
essentially it says
existing table to use the as-row-change-timestamp-clause. You must
either drop the table and recreate with the column defined with the
as-row-change-timestamp-clause or ALTER the table and add a new
column with the as-row-change-timestamp-clause.