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

DB2 precompile error when using CTE's (WITH clause) in COBOL


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Satya Poola

New User


Joined: 29 Dec 2010
Posts: 2
Location: Chennai

PostPosted: Thu Dec 30, 2010 11:31 am
Reply with quote

Hi,
I need to use the following query for hierarchial retrieval

WITH AGCY_LVL (TAX_AGCY,TAX_AGCY_PRNT,LEVEL) AS
(
SELECT TAX_AGCY,TAX_AGCY_PRNT,0
FROM TAX_AGECNCY
WHERE TAX_AGCY = 'PRN'
UNION ALL
SELECT B.TAX_AGCY, B.TAX_AGCY_PRNT, LEVEL + 1
FROM AGCY_LVL A , TAX_AGECNCY B
WHERE A.TAX_AGCY_PRNT = B.TAX_AGCY
AND A.LEVEL < 10
)
SELECT * FROM AGCY_LVL
WHERE TAX_AGCY <> TAX_AGCY_PRNT
ORDER BY LEVEL DESC


This worked fine in SPUFI and QMF and got the result.
But when I tried to include the same in COBOL program, during the DB2 precomplie getting ERROR

DSNH199I E DSNHLEXC LINE 524 COL 17 INVALID KEYWORD "WITH"; VALID SYMBOLS ARE: INCLUDE DECLARE BEGIN END

Can anyone please help me resolve this. Thanks in advance
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Thu Dec 30, 2010 9:03 pm
Reply with quote

Hi Satya,

Welcome to IBMMAINFRAMES!

I did not have any problem compililng and executing a program having CTE.

My cursor looked like,
Code:
************************************************************
 CURSOR DECLARATION                                         
************************************************************
 EXEC SQL                                                   
      DECLARE ECURSOR CURSOR FOR                             
        WITH R(EMPNO,FIRSTNME,MIDINIT,LASTNAME,HIREDATE,JOB,
             SALARY,BONUS,COMM) AS (                         
        SELECT EMPNO,FIRSTNME,MIDINIT,LASTNAME,HIREDATE,JOB,
          SALARY,BONUS,COMM                                 
        FROM BOBT1.EMPLOYEE                                 
        WHERE SEX='M'                                       
        )                                                   
        SELECT EMPNO,FIRSTNME,MIDINIT,LASTNAME,HIREDATE,JOB,
          SALARY,BONUS,COMM                                 
        FROM R                                               
 END-EXEC.                                                   
 ***********************************************************



Thanks,
Sushanth
Back to top
View user's profile Send private message
Satya Poola

New User


Joined: 29 Dec 2010
Posts: 2
Location: Chennai

PostPosted: Fri Dec 31, 2010 9:11 am
Reply with quote

HI Sushanth,

Thanks for the welcome.

I'm having the DECLARE CURSOR statement after the CTE ( i.e the CTE is not in the CURSOR) that is the reason I'm getting precompiler error.

Now it is resolved. Thanks a lot for immediate help icon_smile.gif .
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 IEW2315E 1369 Link error All Other Mainframe Topics 3
No new posts COBOL sorting, with input GDG base COBOL Programming 7
No new posts Need help with ADABAS query (COBOL-AD... All Other Mainframe Topics 0
No new posts Help on IMS -API URL migrating from P... IMS DB/DC 1
No new posts Replacing FILLER with FILLER<SeqNu... DFSORT/ICETOOL 2
Search our Forums:

Back to Top