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: 10211
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 Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


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