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 JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm
No new posts GETMAIN/FREEMAIN query Suja.Sai CICS 9 Tue Jan 31, 2017 12:01 pm


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