View previous topic :: View next topic
|
Author |
Message |
vickyprodigy
New User
Joined: 18 Jul 2007 Posts: 11 Location: Chennai
|
|
|
|
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 |
|
|
hemanth.nandas
Active User
Joined: 18 Aug 2007 Posts: 120 Location: India
|
|
|
|
Hi Vicky,
Post SQLERR Message And SQL Code. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
vickyprodigy
New User
Joined: 18 Jul 2007 Posts: 11 Location: Chennai
|
|
|
|
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. |
|
Back to top |
|
|
hemanth.nandas
Active User
Joined: 18 Aug 2007 Posts: 120 Location: India
|
|
|
|
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 |
|
|
hemanth.nandas
Active User
Joined: 18 Aug 2007 Posts: 120 Location: India
|
|
|
|
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 |
|
|
rpuhlman
New User
Joined: 11 Jun 2007 Posts: 80 Location: Columbus, Ohio
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Yup, i agree
I didn't see any code to use the cursor in the posted code and thought (maybe badly ) 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 |
|
|
omnamashiva
New User
Joined: 24 Sep 2007 Posts: 10 Location: chennai
|
|
|
|
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 |
|
|
|