Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search 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
Author Message
sathish_rathinam

Active User


Joined: 22 Aug 2005
Posts: 57
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
References
PostPosted: Fri May 16, 2008 4:42 pm    Post subject: Re: Query not working ... Reply with quote

sathish_rathinam

Active User


Joined: 22 Aug 2005
Posts: 57
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: 2648
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

Active User


Joined: 22 Aug 2005
Posts: 57
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: 270
Location: Pune, India

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: 280
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
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1