Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Last Update Date

Status
Not open for further replies.

VergeResources

Programmer
Feb 6, 2002
40
US
Is there a way to get the last date a record was inserted into a specific table? I've looked through the sys tables but haven't found any useful dates (only last time a runstat was performed). Thanks in advance.
 
No. Well not as far as I am aware anyway. If you want that sort of information you'll have to build it into the table as a column.

Marc
 
That's what I was afraid of... I actually have this date already built into my table. But, since there are so many records in the table, it takes a long time to retrieve the MAX. For some reason, I haven't had much success adding the date as an index. The query still seems to be slow.

Thanks for the response!
 
VergeResources,

I'm not sure why you can't improve this with an index, may be it's down to your version/operating system etc, not allowing dates to be indexable. I know you can get in a right mess with your index structure using something like dates, as they don't spread evenly. What versions etc do you have.

As an interim soultion maybe you could define another table and insert the date in there each time you update your base table. The "new" table need only contain 1 record, saving your scans and diskspace putting the date on each row.

Just code along the lines

UDPATE TABLE
SET MY_DATE = Current Date

whenever you update the base table.

Not the most elegant solution, I admit. But it may get you out of your current problem, with minimal effort and investigation.

Cheers
Greg
 
We are using DB2 Version 6 on OS/390. There are plans to move to V7, so hopefully that will make a difference.

Thanks for the suggestions!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top