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
 

 

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 Getting -504 Cursor Name GTT-ARTS-CUR... Robin Sulsona DB2 2 Fri Mar 17, 2017 1:43 am
No new posts Release of Adabas Cursor mohitsethi All Other Mainframe Topics 1 Mon Feb 06, 2017 8:36 pm
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am
No new posts Amount field is getting corrupted whe... thesumitk SYNCSORT 5 Tue Oct 18, 2016 8:20 pm
No new posts hot to get details when "EXEC CI... Andi1982 CICS 11 Tue Sep 20, 2016 5:01 pm


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