By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,287 Members | 1,309 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,287 IT Pros & Developers. It's quick & easy.

Applying CURRENT TIMESTAMP On Updates

rickbray66
P: 7
DB2 Express for Windows: DB2 v9.1.200.166


Hello. I've recently started working with DB2. I'm in the process of migrating a DDL from MySQL over to DB2. Consider the following snipet:

Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE `book_unit` (
  2.   `book_unit_id` varchar(32) NOT NULL default '',
  3.   `last_updated` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  4.  
The above statement in MySQL automatically sets the "last_updated" field to the current timestamp upon updates if the data is not supplied in the SQL statement. Is there an easy way to achieve this in DB2 without using a trigger? I've looked at "GENERATED BY DEFAULT" and "FOR EACH ROW ON UPDATE AS ROW CHANGE TIMESTAMP" documentation without much luck.

Any help is greatly appreciated.

Thanks!!


Rick
Jun 25 '07 #1
Share this Question
Share on Google+
1 Reply


rickbray66
P: 7
Still haven't found an easy way to achieve this without using a trigger, so that looks like the route I'm headed.

Just for reference:

A new clause: FOR EACH ROW ON UPDATE ROW CHANGE TIMESTAMP

has been implemented for DB2 9.1 for z/OS.

This is exactly what I'm looking for, but unfortunately, it does not appear to work for DB2 Express 9.1 for Windows.


Rick
Jun 26 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.