IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to get Timestamp ,which the db2 got updated any columns


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
cmsmoon

New User


Joined: 17 Jun 2010
Posts: 75
Location: Chennai

PostPosted: Tue Feb 05, 2013 9:00 pm
Reply with quote

Is possible to get the last timestamp using db2 query,which updated tables using program/tep'2 ?
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue Feb 05, 2013 9:06 pm
Reply with quote

Do you wanted to know the timestamp when record was updated or the timestamp when record was table was updated ?

But both the timestamp cant be retreived via sql unless you have some process of storing those timestamp in a DB2 table
Back to top
View user's profile Send private message
cmsmoon

New User


Joined: 17 Jun 2010
Posts: 75
Location: Chennai

PostPosted: Tue Feb 05, 2013 9:08 pm
Reply with quote

Yes ,Extactly..
But i do not have Timestamp field in that table
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue Feb 05, 2013 9:12 pm
Reply with quote

Dear cmsmoon,


Quote:
Do you wanted to know the timestamp when record was updated or the timestamp when record was updated ?


With all due respect to you reminding you gently that You did not answer this question yet

But anyway what you could do is try the following options

Alter the table by adding a new field of datatype TIMESTAMP and update it with the CURRENT TIMESTAMP when updating the table
so you can qury the table for MAX(TIMESTAMP) to know the latest update happened

or if you just need it for reporting purpose and dont bother to refer it in future you can generate the X(26) programmatically
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Tue Feb 05, 2013 9:14 pm
Reply with quote

Dear Pandora,

Quote:
Do you wanted to know the timestamp when record was updated or the timestamp when record was table was updated ?


With all due respect, the 'or' portion of the question is confusing.
Back to top
View user's profile Send private message
cmsmoon

New User


Joined: 17 Jun 2010
Posts: 75
Location: Chennai

PostPosted: Tue Feb 05, 2013 9:19 pm
Reply with quote

Sorry for confusion.

I tried the below query ,but it support only ver 9 and above

SELECT * FROM TAB
WHERE ROW CHANGE TIMESTAMP FOR TAB <= CURRENT TIMESTAMP AND
ROW CHANGE TIMESTAMP FOR TAB >= CURRENT TIMESTAMP - 30 days;
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue Feb 05, 2013 9:20 pm
Reply with quote

Dave,

The quote is editted icon_smile.gif
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Tue Feb 05, 2013 9:22 pm
Reply with quote

Pandora,

Quote:
Do you wanted to know the timestamp when record was updated or the timestamp when record was updated ?


Now both sides of the 'or' ask the same question?
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue Feb 05, 2013 9:24 pm
Reply with quote

I realised it by the time I elapsed the grace time of correcting things
icon_redface.gif

All I wanted to ask was if TS wants the timestamp when the table is updated or the timestamp when record for a key is updated
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Tue Feb 05, 2013 9:32 pm
Reply with quote

Hi cmsmoon,

Suggest you describe what your actual requirement is... That might help the experts here to suggest an appropriate solution...

cmsmoon wrote:
Sorry for confusion.

I tried the below query ,but it support only ver 9 and above

SELECT * FROM TAB
WHERE ROW CHANGE TIMESTAMP FOR TAB <= CURRENT TIMESTAMP AND
ROW CHANGE TIMESTAMP FOR TAB >= CURRENT TIMESTAMP - 30 days;

What version of DB2 are you using ?
You have used ROW CHANGE TIMESTAMP - did you do any research to understand what is the functionality of that ? [I have not worked in DB2 now for the last 5 years but did a quick google and doesnt look to be fitting your 'problem' ]
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Feb 05, 2013 10:19 pm
Reply with quote

Quote:
Is possible to get the last timestamp using db2 query,which updated tables using program/tep'2 ?


If I understand correctly the TS wants to know <what> and <when> was updated using DSNTEP2
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Remote Unload of CLOB Columns DB2 6
No new posts Increase the number of columns in the... IBM Tools 3
No new posts Insert system time/date (timestamp) u... DFSORT/ICETOOL 5
No new posts Timestamp difference and its average ... DB2 11
Search our Forums:

Back to Top