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
 

 

Query not working ...

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
sathish_rathinam

New User


Joined: 22 Aug 2005
Posts: 59
Location: india

PostPosted: Fri May 16, 2008 4:42 pm    Post subject: Query not working ...
Reply with quote

Code:
EXEC SQL
DECLARE CSR3_DOC CURSOR WITH HOLD FOR
SELECT
 DOC_CATEGORY_CODE
,DATE_TIME_PRODUCED
FROM
 TEJDOCD_DOC_DAT
WHERE
 DOC_CATEGORY_CODE = :TEJDOCD.DOC-CATEGORY-CODE
 AND (MONTHS(CURRENT DATE) – MONTHS(DATE(DATE_TIME_PRODUCED)))>:
TEJRFDC.DOC-RETENTION-PD
FOR
 FETCH ONLY
END-EXEC.



I need to find the difference between two dates in terms of months in this query.but iam getting SQL error -440.can u pls help me out .
Back to top
View user's profile Send private message

sathish_rathinam

New User


Joined: 22 Aug 2005
Posts: 59
Location: india

PostPosted: Fri May 16, 2008 4:50 pm    Post subject:
Reply with quote

Also ,

Code:
EXEC SQL
DECLARE CSR3_DOC CURSOR WITH HOLD FOR
SELECT
DOC_CATEGORY_CODE
,DATE_TIME_PRODUCED
FROM
TEJDOCD_DOC_DAT
WHERE
DOC_CATEGORY_CODE = :TEJDOCD.DOC-CATEGORY-CODE
AND (YEARS(CURRENT DATE) – YEARS(DATE(DATE_TIME_PRODUCED)))>:
TEJRFDC.DOC-RETENTION-PD
FOR
FETCH ONLY
END-EXEC. 

need to find the difference between two dates in terms of years in this query.but iam getting SQL error -440.can u pls help me out .
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Fri May 16, 2008 4:56 pm    Post subject: Reply to: Query not working ...
Reply with quote

why dont' You try to help Yourself by looking at the manual

did You care to research the sqlcode ?

Quote:
sqlstate: 42884
message: No function or procedure was found with the specified name and compatible arguments.
sqlcode: -440


<something every poster should have read and understood read....>
Back to top
View user's profile Send private message
sathish_rathinam

New User


Joined: 22 Aug 2005
Posts: 59
Location: india

PostPosted: Fri May 16, 2008 5:00 pm    Post subject:
Reply with quote

can u pls tell me how to correct the sqls above as per my requirement
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 356
Location: New York

PostPosted: Fri May 16, 2008 5:08 pm    Post subject:
Reply with quote

As per my knowledge, there is no MONTHS function in DB2. We can extract months using MONTH function and Years using YEAR function.

Please look at the following site. You can find for YEAR also.

http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.admin.doc/doc/r0000830.htm

KSK
Back to top
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Fri May 16, 2008 5:38 pm    Post subject:
Reply with quote

another post about month difference between two dates
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