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

Delete records based on TIMESTAMP from a tabel


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

New User


Joined: 26 Nov 2008
Posts: 9
Location: Hyderabad

PostPosted: Thu Nov 27, 2008 2:03 pm
Reply with quote

Hi

I created a tabel whose one of the column value is UPDATE_TIMESTAP this time stamp will be the value when the record has been laoded into the tabel(for example: today if i load a record at 12PM value(UPDATED_TIMESTAMP) loads into table is 2008-11-27-12.33.27.238657)

So now i want issue a delete query where All the records having (UPDATE_TIMESTAMP + 24 months) > TODAY’s date must be deleted from the tabel. i have a confusion with the value loaded and current timestamp valueloaded is in the format of (2008-11-27-12.33.27.238657) and current timestamp is 20081127123327238657 how can i compare both value for deleting the record from table..

FYI i coded as:

EXEC SQL DELETE FROM PENDTABL WHERE UPDATE_TIMESTAMP > CUREENT_TIMESTAMP - 24months ;

will it works or need any corrections
Back to top
View user's profile Send private message
shaikfayaz

New User


Joined: 26 Nov 2008
Posts: 9
Location: Hyderabad

PostPosted: Fri Nov 28, 2008 8:02 pm
Reply with quote

Hi

i want to delete records whose timestamp is more than 24months.. how can i proceed to this.

FYI i coded as:

EXEC SQL DELETE FROM PENDTABL WHERE UPDATE_TIMESTAMP > CUREENT_TIMESTAMP - 24months ;

will it works or need any corrections
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Fri Nov 28, 2008 9:18 pm
Reply with quote

Code:


DELETE FROM PENDTABL WHERE UPDATE_TIMESTAMP > CURRENT TIMESTAMP - 2 YEARS

Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Fri Nov 28, 2008 9:21 pm
Reply with quote

24 months will also work ...
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Sat Nov 29, 2008 8:15 am
Reply with quote

I think you meant that > sign to be a < sign didn't you?
Back to top
View user's profile Send private message
shaikfayaz

New User


Joined: 26 Nov 2008
Posts: 9
Location: Hyderabad

PostPosted: Mon Dec 01, 2008 5:17 pm
Reply with quote

But the UPdate_TIMESTAMP is the value which is edited while loading into the table for example;2008-11-27-12.33.27.238657

If i pull the value CUREENT TIMESTAMP the value will be 20081127123327238657, How can we compare a relation between them ?
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Mon Dec 01, 2008 6:02 pm
Reply with quote

"If i pull the value CUREENT TIMESTAMP the value will be 20081127123327238657,..."
Look again at the format of CURRENT TIMESTAMP in your DB2 manual.
Back to top
View user's profile Send private message
shaikfayaz

New User


Joined: 26 Nov 2008
Posts: 9
Location: Hyderabad

PostPosted: Mon Dec 01, 2008 8:48 pm
Reply with quote

Even though there is change in time representation format like HH:MM:SS in CURRENT TIME STAMP value, there would be any change in YYYYMMDD field,

I mean: UPDATED TIME STAMP VALUE = 2008-11-27-12.33.27.238657
CURRENT TIME STAMP VALUE = 2008112712:34:45123957

How the date format will be evaluated in expression ?
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Mon Dec 01, 2008 8:55 pm
Reply with quote

See section 1.1.9 in the DB2 Application Programming and SQL Guide. The format for CURRENT TIMESTAMP is not what you indicate.
Back to top
View user's profile Send private message
shaikfayaz

New User


Joined: 26 Nov 2008
Posts: 9
Location: Hyderabad

PostPosted: Thu Dec 11, 2008 8:31 pm
Reply with quote

Terry Thank you very much for your assistance.

but unfortunetly i do not have the manual.. If you don't mind can you fwd that to my id e-addr removed per forum rules, so that i will chck and let you know the results.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Thu Dec 11, 2008 9:31 pm
Reply with quote

Click "IBM Manuals" at the top of this screen.
Back to top
View user's profile Send private message
shaikfayaz

New User


Joined: 26 Nov 2008
Posts: 9
Location: Hyderabad

PostPosted: Thu Dec 11, 2008 10:17 pm
Reply with quote

Hi Terry,

I am glad to inform you that i am able to Delete the records whose timestamp is greater than 24months

Thank you very much for you support & my pleasure to meet u in this forumn
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 0
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts DELETE SPUFI DB2 1
No new posts To get the count of rows for every 1 ... DB2 3
No new posts DSNTIAUL driven delete IBM Tools 0
Search our Forums:

Back to Top