Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 reg query on DYNALLOC feature raghuraman123 SYNCSORT 12 Wed Jan 10, 2018 2:42 pm
No new posts query to fetch record which has only ... maxsubrat DB2 12 Mon Dec 11, 2017 5:03 pm
No new posts How to query MAXGENS of an existing P... Chuchulo Hatyzak JCL & VSAM 4 Wed Nov 22, 2017 10:23 pm
No new posts Native SQL Query kishpra DB2 1 Wed Nov 22, 2017 8:38 pm
No new posts Query on IEFBR14 with GDG Ashishpanpaliya JCL & VSAM 4 Tue Nov 07, 2017 8:34 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us