Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Need a Delete query

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Need a Delete query
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    Post subject:
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: 205
Location: Bangalore

PostPosted: Mon Feb 02, 2009 10:04 pm    Post subject: Reply to: Need a Delete query
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts JCL to delete component in a package sundaram.naveen Compuware & Other Tools 14 Tue Nov 29, 2016 6:21 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us