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

-501 db2 error -important


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Nithya.U.M
Warnings : 1

New User


Joined: 11 Nov 2008
Posts: 21
Location: India

PostPosted: Fri Dec 05, 2008 1:02 pm
Reply with quote

Hi ,
I am getting a -501 error -> cursor not open on fetch. When the program is run on debug mode this error comes in the second fetch of the cursor in a loop. No explicit roll back , commit or close cursor is performed after the first fetch and declare, open , fetch and close cursor statements are given in proper manner. I am unable to understand why this error occurred.Is there any other reason for this error ? Please help .

Regards,
Nithya
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Fri Dec 05, 2008 1:27 pm
Reply with quote

Nithya,

It would be very helpfull for other to suggest you, if you post part of your code.

Sushanth
Back to top
View user's profile Send private message
Nithya.U.M
Warnings : 1

New User


Joined: 11 Nov 2008
Posts: 21
Location: India

PostPosted: Fri Dec 05, 2008 1:57 pm
Reply with quote

Sushanth,
here is a part of the code which has the cursor flow.

A1000-APPLICATION-PROCESS.
PERFORM A9000-READ-INPUT
PERFORM A9001-DECLARE-FACILITY-CURSOR
PERFORM A9006-DECLARE-SL-CMPNT-DTL
PERFORM A9008-FETCH-SL-CMPNT-CURSOR
PERFORM A9002-PROCESS-FACILITIES
UNTIL WS-IN-FILE-STATUS-EOF
PERFORM A9009-WRITE-TOTALS-FILE
PERFORM A9010-CLOSE-FACILITY-CURSOR
PERFORM A9011-CLOSE-SLCMPNT-CURSOR
PERFORM A9500-WRAP-UP.
***************************************************
A9002-PROCESS-FACILITIES.

PERFORM A9003-FETCH-FACILITY-CURSOR.
IF WS-FIRST-FLAG = 1
MOVE KY-FACIL-NO OF CU20TB09 TO WS-MAX-FACIL-NO
COMPUTE WS-FIRST-FLAG = WS-FIRST-FLAG + 1
END-IF
MOVE KY-FACIL-NO OF CU20TB09 TO WS-TAB-KY-FACIL-NO.
MOVE KY-PREM-NO OF CU20TB09 TO WS-TAB-KY-PREM-NO.
MOVE KY-BA OF CU20TB09 TO WS-TAB-KY-BA.
MOVE KY-GRID-NO-RFMS OF CU20TB09 TO WS-TAB-KY-GRID-NO-RFMS
WS-INT-KY-GRID-NO-RFMS.
and many more moves and logic included in this para.

PERFORM A9001-DECLARE-FACILITY-CURSOR .

A9001-DECLARE-FACILITY-CURSOR.
EXEC SQL
DECLARE FACILITY CURSOR FOR
SELECT
KY_FACIL_NO,
KY_PREM_NO,
KY_BA,
KY_GRID_NO_RFMS,
AD_LN,
AD_LN_2,
KY_CUST_NO(many more fields)
FROM
SL_FACILITIES
ORDER BY KY_FACIL_NO
END-EXEC

EXEC SQL
OPEN FACILITY
END-EXEC

A9003-FETCH-FACILITY-CURSOR.
EXEC SQL
FETCH FACILITY
INTO
:CU20TB09.KY-FACIL-NO,
:CU20TB09.KY-PREM-NO,
:CU20TB09.KY-BA,
:CU20TB09.KY-GRID-NO-RFMS,
:CU20TB09.AD-LN,
:CU20TB09.AD-LN-2 and many more fields
A9010-CLOSE-FACILITY-CURSOR.
EXEC SQL
CLOSE FACILITY
END-EXEC.

currently i am getting this error only while second fetch of the facility cursor inside the process-para.
hope this will make the situation clear. Please help in resolving this issue.
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Fri Dec 05, 2008 2:21 pm
Reply with quote

Please check SQL RETURN CODE after each and every database call, ie, OPEN, FETCH, CLOSE cursors here.
Back to top
View user's profile Send private message
Nithya.U.M
Warnings : 1

New User


Joined: 11 Nov 2008
Posts: 21
Location: India

PostPosted: Fri Dec 05, 2008 2:28 pm
Reply with quote

Gnanas,
I have debugged the entire code line by line and i am getting sqlcode as zero for first fetch of facility cursor but during second fetch it is -501 .

Thanks and regards,
Nithya
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Fri Dec 05, 2008 2:55 pm
Reply with quote

Nithya,

Are you doing any COMMIT or ROLLBACK operations.
Which might also close the CURSORS.

Sushanth
Back to top
View user's profile Send private message
Nithya.U.M
Warnings : 1

New User


Joined: 11 Nov 2008
Posts: 21
Location: India

PostPosted: Fri Dec 05, 2008 3:43 pm
Reply with quote

Thanks everyone .
the system was performing an autocommit by updating a table during a read of another file in the same para. :-). This issue is resolved and thanks once again for the replies.
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 Error to read log with rexx CLIST & REXX 11
No new posts Error when install DB2 DB2 2
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts Error while running web tool kit REXX... CLIST & REXX 5
No new posts Getting Error while trying to establi... DB2 3
Search our Forums:

Back to Top