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
 
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: 10396
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: 355
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 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 REXX LISTDSI () SMSINFO is not working upendrasri CLIST & REXX 4 Fri Nov 17, 2017 11:33 am

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