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

Need a Delete query


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

New User


Joined: 15 Aug 2008
Posts: 5
Location: PUNE

PostPosted: Mon Feb 02, 2009 8:14 pm
Reply with quote

Hi,

My requirement is as follows. I need a query to Delete rows from Table A based on BILL_DATE is <= CURRENT DATE - 7 YERAS. BILL_DATE column is defined as CHAR (6) in TABLE A. So if i'll write Delete from Table A WHERE BILL_DATE is <= CURRENT DATE - 7 YERAS, getting sqlcode -180 because column is defined as char. As per my knowledge SUBSTR function won't support while Deleting from Table.

If anyone having any ideas please let me know.

Thanks
John
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon Feb 02, 2009 9:03 pm
Reply with quote

I wish designers would learn about DB2 before they start designing. What is the format of the data in BILL_DATE.
Back to top
View user's profile Send private message
Ajay Baghel

Active User


Joined: 25 Apr 2007
Posts: 206
Location: Bangalore

PostPosted: Mon Feb 02, 2009 10:04 pm
Reply with quote

Hi John,

If the BILL_DATE is character string like below:
'2002-10-20'

You can issue the below query:
Delete from Table A WHERE
DATE(BILL_DATE) is <= ( CURRENT DATE - 7 YEARS )


Thanks,
Ajay
Back to top
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Mon Feb 02, 2009 10:20 pm
Reply with quote

Quote:
-180 THE DATE, TIME, OR TIMESTAMP VALUE value IS INVALID

Explanation: The length or string representation of a DATE, TIME, or
TIMESTAMP value does not conform to any valid format.

It does not say a word about the column being CHAR.
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 DELETE SPUFI DB2 1
No new posts DSNTIAUL driven delete IBM Tools 0
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts How to delete a user's alias from the... JCL & VSAM 11
Search our Forums:

Back to Top