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
 
Pre-Compiler Bug with DSNH520I message?

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

New User


Joined: 13 Jun 2012
Posts: 77
Location: United States

PostPosted: Thu Aug 09, 2018 9:00 pm    Post subject: Pre-Compiler Bug with DSNH520I message?
Reply with quote

I am getting DSNH520I on a dynamic cursor.
(THE OPEN STATEMENT FOR CURSOR "GETDOC" IS INVALID BECAUSE THE CURSOR WAS DEFINED BY AN ALLOCATE CURSOR STATEMENT.
Here is my code:

MOVE 'SELECT DOC_TYPE, BATCH, DOC_ID, DATE_TIME, '
TO VAR-TEXT (1:43).
MOVE 'MESSAGE_ID, MESSAGE_TEXT FROM PFIAFNT.SCISTAT '
TO VAR-TEXT (44:46).
MOVE 'WHERE DATE_TIME > CURRENT_TIMESTAMP - '
TO VAR-TEXT (90:38).
MOVE WS-DAYS TO VAR-TEXT (128:4).
MOVE ' DAYS' TO VAR-TEXT (132:5).
MOVE 136 TO VAR-LEN.
IF WS-CONTROL = 'NSA'
MOVE ' ORDER BY DOC_TYPE, BATCH, DOC_ID, DATE_TIME
TO VAR-TEXT (137:44)
ADD 44 TO VAR-LEN
END-IF.
PERFORM P190-PREPARE.

Other code.....


P190-PREPARE.
EXEC SQL
PREPARE SELECT_VERB FROM :VAR-STRING
END-EXEC
EXEC SQL
DECLARE GETDOC CURSOR FOR SELECT_VERB
END-EXEC
EXEC SQL
OPEN GETDOC
END-EXEC


However, if I take the code in P190-PREPARE and move it to where the perform was, it works fine:

MOVE 'SELECT DOC_TYPE, BATCH, DOC_ID, DATE_TIME, '
TO VAR-TEXT (1:43).
MOVE 'MESSAGE_ID, MESSAGE_TEXT FROM PFIAFNT.SCISTAT '
TO VAR-TEXT (44:46).
MOVE 'WHERE DATE_TIME > CURRENT_TIMESTAMP - '
TO VAR-TEXT (90:38).
MOVE WS-DAYS TO VAR-TEXT (128:4).
MOVE ' DAYS' TO VAR-TEXT (132:5).
MOVE 136 TO VAR-LEN.
IF WS-CONTROL = 'NSA'
MOVE ' ORDER BY DOC_TYPE, BATCH, DOC_ID, DATE_TIME'
TO VAR-TEXT (137:44)
ADD 44 TO VAR-LEN
END-IF.

EXEC SQL
PREPARE SELECT_VERB FROM :VAR-STRING
END-EXEC
EXEC SQL
DECLARE GETDOC CURSOR FOR SELECT_VERB
END-EXEC
EXEC SQL
OPEN GETDOC
END-EXEC

Either way, the fetch statement is coded after the open.
Back to top
View user's profile Send private message

John Poulakos

New User


Joined: 13 Jun 2012
Posts: 77
Location: United States

PostPosted: Thu Aug 09, 2018 9:09 pm    Post subject:
Reply with quote

I found the problem. Just in case anyone else runs into this, when you do dynamic SQL the PREPARE, DECLARE, OPEN, FETCH and CLOSE statements must be in that physical order; logical order doesn't matter.

In my case the CLOSE was physically ahead of the others when I performed P190.
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 Error while initiation CICS program f... Ashishpanpaliya CICS 3 Mon Jul 16, 2018 5:12 pm
No new posts Trap the jcl error message or maxcc i... ankita agarwal CLIST & REXX 5 Fri May 18, 2018 2:08 pm
No new posts HSM log message : GENMSG -ROU/1 -NL/! kadiresh JCL & VSAM 1 Sat Mar 03, 2018 5:52 pm
No new posts No message in reply queue!! Vignesh Sid Java & MQSeries 3 Thu Jan 11, 2018 10:45 am
No new posts Default Message in Rexx cvnlynn CLIST & REXX 9 Wed Aug 02, 2017 12:38 am

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