IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Cursor Declaration with "WITH CLAUSE"


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts PuTTY - "User is not a surrogate... IBM Tools 5
No new posts Newbie Stuck on "Duplicate Datas... TSO/ISPF 5
No new posts To search DB2 table based on Conditio... DB2 1
No new posts RABBIT HOLE NEEDED - "Live"... All Other Mainframe Topics 0
No new posts Using PARM=('JPn"&SYMBOL&quo... DFSORT/ICETOOL 2
Search our Forums:

Back to Top