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

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

New User


Joined: 21 Jul 2007
Posts: 19
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
References
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: 19
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

Senior Member


Joined: 13 Feb 2004
Posts: 354
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

Senior Member


Joined: 13 Feb 2004
Posts: 354
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
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