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

Cursor not declared error


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vickyprodigy

New User


Joined: 18 Jul 2007
Posts: 11
Location: Chennai

PostPosted: Thu Oct 18, 2007 12:36 pm
Reply with quote

Hi,
i am getting cursor not declared error. But i have declared it before the opening it . i am opening and fetching it in Procedure division. ill paste the code below. kindly have a look and point out the mistake i have made.


WORKING-STORAGE SECTION.
EXEC SQL
INCLUDE SQLCA
END-EXEC.
EXEC SQL
INCLUDE TERRLOG
END-EXEC.
01 WS-START-STMP PIC X(28).
01 WS-END-STMP PIC X(28).
77 SCODE PIC +999.
77 FS PIC X(2).

PROCEDURE DIVISION.
OPEN OUTPUT OFILE.
PERFORM 01-DCLR-CUR-ERR1.
EXEC SQL OPEN ERR1 END-EXEC.
PERFORM 02-WRITEGDG UNTIL SQLCODE NOT = 0.
EXEC SQL CLOSE ERR1 END-EXEC.
CLOSE OFILE.
STOP RUN.

01-DCLR-CUR-ERR1
MOVE START-STMP TO WS-START-STMP.
MOVE END-STMP TO WS-END-STMP.
EXEC SQL
DECLARE ERR1 CURSOR FOR
SELECT PROGRAM_NAME,
TRANS_TYPE_CD,
PROGRAM_DATA,
SQLCA_SQLCODE
FROM TERROR_LOG
WHERE APPLIED_DTSTMP >= :WS-START-STMP AND
APPLIED_DTSTMP < :WS-END-STMP
END-EXEC.
01-EXIT. EXIT
Back to top
View user's profile Send private message
hemanth.nandas

Active User


Joined: 18 Aug 2007
Posts: 120
Location: India

PostPosted: Thu Oct 18, 2007 12:48 pm
Reply with quote

Hi Vicky,

Post SQLERR Message And SQL Code.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Oct 18, 2007 12:50 pm
Reply with quote

Hello,

I believe you want to move the cursor declaration to working-storage and then include code to use the cursor in the procedure division.
Back to top
View user's profile Send private message
vickyprodigy

New User


Joined: 18 Jul 2007
Posts: 11
Location: Chennai

PostPosted: Thu Oct 18, 2007 2:17 pm
Reply with quote

Hi Hemanth,
i got a JCLERROR in precompiling. this is the message i got. have a look

DSNH527I W DSNHOPTS THE PRECOMPILER ATTEMPTED TO USE THE DB2-SUPPLIED DSNHDECP MODULE
DSNH504I E DSNHSMUD LINE 47 COL 26 CURSOR "ERR1" WAS NOT DECLARED
OPEN ERR1

DSNH521I W DSNHSM3 LINE 49 COL 21 THE CLOSE FOR CURSOR "ERR1" IS ASSUMED TO APPLY TO A DYNAMIC ALLOCATE CURSOR STATEMENT
CLOSE ERR1


Hi scherrer,
i tried movin it to WS section also. even then it didnt work. icon_sad.gif
Back to top
View user's profile Send private message
hemanth.nandas

Active User


Joined: 18 Aug 2007
Posts: 120
Location: India

PostPosted: Thu Oct 18, 2007 2:36 pm
Reply with quote

Hi Vicky,

Quote:
| DSNH527I ERROR: THE PRECOMPILER ATTEMPTED TO USE THE DB2-SUPPLIED DSNHDECP
| MODULE.


| Explanation: The DSNHDECP module that is supplied by DB2 is being used to
| run the DB2 precompiler. The precompiler requires site-dependent settings
| that are specified in the DSNHDECP module that was created when DB2 was
| installed. The installation-generated DSNHDECP module typically resides in
| the SDSNEXIT library.

| System Action: Processing halts.


| User Response: Check the STEPLIB, JOBLIB, or system linbklist
| concatenation used in the DB2 address spaces. To ensure that the proper
| DSNHDECP module is used, verify that the library that contains the
| DSNHDECP module that is generated during installation precedes the
| SDSNLOAD library that contains the DSNHDECP module that was supplied by
| DB2.


| System Programmer Response: The following actions are required to enable
| the DSNH CLIST to load your user-supplied DSNHDECP module rather than the
| DB2 DSNHDECP module that was supplied by DB2:


| The JOBLIB or STEPLIB concatenation of any job or TSO userid that
| calls DSNH needs to allocate the library where the user-supplied
| DSNHDECP module resides (usually prefix.SDSNEXIT) ahead of the library
| where the DB2-supplied DSNHDECP module resides (prefix.SDSNLOAD).

| The DSNH call should include the PCLOAD parameter, and it should be
| coded as shown here: PCLOAD('*(DSNHPC)').


Ask your admin people To correct these things.

And let us know even after stuck somewhere.

Its not a Problem with DECLARATION.
Back to top
View user's profile Send private message
hemanth.nandas

Active User


Joined: 18 Aug 2007
Posts: 120
Location: India

PostPosted: Thu Oct 18, 2007 2:41 pm
Reply with quote

Hi Dick,

Quote:
I believe you want to move the cursor declaration to working-storage and then include code to use the cursor in the procedure division.


Cursor can also be Declare in Procedure Division. But it has to be Declare before Opening/Fetching/close it.
Back to top
View user's profile Send private message
rpuhlman

New User


Joined: 11 Jun 2007
Posts: 80
Location: Columbus, Ohio

PostPosted: Thu Oct 18, 2007 5:30 pm
Reply with quote

Yes ... you can declare your cursor in the procedure division, however, the cursor declaration must be coded positionally before the code for the open cursor. Performing the declaration and then executing the open cursor does not work if the declaration is below the open. This is why a lot of programmers place their cursor declarations in working storage. A lot of programs will place the cursor declaration right before the open cursor statement and then perform that paragraph.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Oct 18, 2007 7:48 pm
Reply with quote

Hello,

Yup, i agree icon_smile.gif

I didn't see any code to use the cursor in the posted code and thought (maybe badly icon_redface.gif ) that if the declare was re-located, the code to use the cursor might be put at that location (where the declare had been) in the program.
Back to top
View user's profile Send private message
omnamashiva

New User


Joined: 24 Sep 2007
Posts: 10
Location: chennai

PostPosted: Thu Oct 18, 2007 10:14 pm
Reply with quote

Hi Friend,
i can give some tip regarding your problem
1. check syntax declaration of the cursor (start from column 12)
2. Avoid of using DB2 keywords as cursor, table name etc
3. add the DCLGEN , tables going to use in that program
If we you need more information , let me know

Thanks,
Arunachalla
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Error when install DB2 DB2 2
No new posts Duplicate transid's declared using CEDA CICS 3
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts Error while running web tool kit REXX... CLIST & REXX 5
Search our Forums:

Back to Top