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
 
Cursor Declaration with "WITH CLAUSE"

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

New User


Joined: 21 Jul 2007
Posts: 27
Location: Chennai

PostPosted: Mon May 19, 2008 6:56 pm    Post subject: Cursor Declaration with "WITH CLAUSE"
Reply with quote

Hi priyesh,

I have used the below CURSOR declaration with "WITH CLAUSE".
If i use this query in SPUFI its working fine. But in application program i am getting pre-compiler error message as below:

"INVALID,KEYWORD "ORDER"; VALID SYMBOLS ARE: ) UNION EXCEPT"

QUERY:
DECLARE ACCOUNT-CURSOR CURSOR FOR
WITH POS_Name1
(Column_1,Column_2,Column_3) AS
(SELECT Column_1,Column_2,Column_3
FROM Table1 T1
WHERE Column_4 = 'XXXXXXXX'
AND Column_3 <> 0)
,Pos_Name2(V_Col1) AS
(SELECT V1.V_Col1
FROM View1 V1
WHERE V1.V_Col2 = 'YY'
AND v1.V_Col3 = 'XXXXXXXX'
AND v1.V_Col4 = 1
ORDER BY v1.V_Col5 DESC
,v1.V_Col6 DESC
FETCH FIRST ROW ONLY)
SELECT T1.Column_1,T1.Column_2,T1.Column_3,v1.V_Col1
FROM POS_Name1 T1,POS_Name2 V1

Can any you help me in this.
Back to top
View user's profile Send private message

manikumar_711
Currently Banned

New User


Joined: 11 Sep 2007
Posts: 7
Location: Chennai

PostPosted: Sun Jun 29, 2008 2:59 pm    Post subject: with clause error
Reply with quote

Hi kalaikala ,
I heared ur name in somewhere else. can you check your query again. some small mistakes u did it. syntax, , : like this .


Thanks & Regards,
MANIKUMAR
Back to top
View user's profile Send private message
kalaikala

New User


Joined: 21 Jul 2007
Posts: 27
Location: Chennai

PostPosted: Wed Jul 02, 2008 4:33 pm    Post subject:
Reply with quote

Hi Mani,

If i remove below code then its working fine.

ORDER BY v1.V_Col5 DESC
,v1.V_Col6 DESC
FETCH FIRST ROW ONLY
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Wed Jul 02, 2008 5:44 pm    Post subject:
Reply with quote

WITH clause is used to construct and MQT ...

use ORDER BY v1.V_Col5 DESC
,v1.V_Col6 DESC
FETCH FIRST ROW ONLY)

in your select clause ...
Back to top
View user's profile Send private message
ascelepius

New User


Joined: 16 Jun 2008
Posts: 35
Location: bangalore

PostPosted: Wed Jul 02, 2008 10:51 pm    Post subject: Reply to: Cursor Declaration with "WITH CLAUSE"
Reply with quote

Correction ashimer, thats a CTE(Common Table Expression) not an MQT...

regards,
asci(i)
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Jul 03, 2008 9:32 pm    Post subject:
Reply with quote

You are right asci ... Sorry for the typo ...
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 Date in where clause - Windows Karthikeyan Subbarayan DB2 9 Wed Nov 15, 2017 9:07 pm
No new posts -502 Error - Cursor already open anand jeyapaul DB2 7 Sun Oct 29, 2017 4:22 am
No new posts Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts Changeman get multiple "Browse C... elixir1986 Compuware & Other Tools 4 Fri Jul 14, 2017 1:48 am

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