If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > can I UPDATE based on INSERT timestamp

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-19-11, 02:22
mkhapali mkhapali is offline
Registered User
 
Join Date: May 2011
Posts: 3
can I UPDATE based on INSERT timestamp

Hello Team,

I need information on an UPDATE statement. Is there a possibility to UPDATE a set of rows based on the range of timestamp they have been INSERTed?

For example,

I want to UPDATE the rows which were INSERTed between
2008-01-01-00.00.00.000000 and 2008-12-31-00.00.00.000000

Can you please assist me here.

Thank you.
Reply With Quote
  #2 (permalink)  
Old 05-19-11, 03:18
nvk@vhv nvk@vhv is offline
Registered User
 
Join Date: Jan 2010
Posts: 294
Hi,

UPDATE - IBM DB2 9.7 for Linux, UNIX, and Windows

update <TABLE> set <COLUMN_YOU_WANT_TO_UPDATE> = NEW_VALUE where <TIMESTAMP_COLUMN> between '2008-01-01-00.00.00.000000' and '2008-12-31-00.00.00.000000'

If you update to many rows at once, you might blow your Transactionlog.
Reply With Quote
  #3 (permalink)  
Old 05-19-11, 10:10
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Quote:
Originally Posted by nvk@vhv View Post
update <TABLE> set <COLUMN_YOU_WANT_TO_UPDATE> = NEW_VALUE where <TIMESTAMP_COLUMN> between '2008-01-01-00.00.00.000000' and '2008-12-31-00.00.00.000000'
That <TIMESTAMP_COLUMN> should of course already be in that table, and it should have been declared
"WITH DEFAULT"
If not, there is no way to ever find out when precisely a row had been inserted into the table.
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
  #4 (permalink)  
Old 05-23-11, 07:22
mkhapali mkhapali is offline
Registered User
 
Join Date: May 2011
Posts: 3
Hi team..
thanks for the information..

If <TIMESTAMP_COLUMN> this column is not defined in the concerned table, then how do a USER go with updating his table for this requirement ?

Do anyone know, if such kind of situation exists with other users? Updating rows based on INSERT timestamps..?

thank you
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On