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

-502 Error - Cursor already open


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

New User


Joined: 26 Oct 2017
Posts: 12
Location: india

PostPosted: Sun Oct 29, 2017 4:22 am
Reply with quote

Hi

My PL/I program is calling a Cobol DB2 Stored procedure which has a cursor.

Only a open cursor is coded in the Cobol DB2 Stored procedure.

How do I close the cursor in the called program from the calling program(PL/I). the close or commit statement in the calling program is not working.

I am getting error

DSNT408I SQLCODE = -502, ERROR: THE CURSOR IDENTIFIED IN AN OPEN STATEMENT IS ALREADY OPEN
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Mon Oct 30, 2017 4:28 pm
Reply with quote

Why do you want to close the cursor in the called program?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Mon Oct 30, 2017 5:21 pm
Reply with quote

Your message indicates that you are trying to open the cursor - not close it. Why not close the cursor in the called program? You may need to call it with a parameter so that it knows to close the cursor.
Back to top
View user's profile Send private message
anand jeyapaul

New User


Joined: 26 Oct 2017
Posts: 12
Location: india

PostPosted: Mon Oct 30, 2017 8:50 pm
Reply with quote

Nic/Rohit..Thank you for your suggestion. We cannot close the cursor in the called program as that is a common stored procedure run by another group. The stored proc is called by java programs...Hence we are trying to close the cursor in the calling program.

Regards

Anand Jeyapaul
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Mon Oct 30, 2017 9:42 pm
Reply with quote

So how does that other group close the cursor in their called programs?
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Mon Oct 30, 2017 10:15 pm
Reply with quote

It seems like that the cursor in the stored procedure need NOT be closed. If you close it then you'll Not get your result set back.

Read here: https://www.ibm.com/support/knowledgecenter/en/SSEPEK_11.0.0/apsg/src/tpc/db2z_writeexternalprocdrda.html

Example: https://www.ibm.com/support/knowledgecenter/en/SSEPEK_11.0.0/apsg/src/tpc/db2z_xmpcobolstoredproceduregeneral.html
https://www.ibm.com/support/knowledgecenter/en/SSEPEK_11.0.0/apsg/src/tpc/db2z_xmpcobolstoredprocedure.html

.
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Tue Oct 31, 2017 2:05 am
Reply with quote

Cursors in stored procedure will Not be closed in the stored procedure program. They will only be opened. Then, your PL/1 program will fetch and close the cursor (after associate locators and allocate cursor).

So, I think what you were doing in your earlier post is correct. You should concentrate on why you would get a -440.

You would need to check the possible causes step by step and make sure nothing is missed (start with the routine name and post the error message for -440).

.
Back to top
View user's profile Send private message
anand jeyapaul

New User


Joined: 26 Oct 2017
Posts: 12
Location: india

PostPosted: Tue Oct 31, 2017 2:23 am
Reply with quote

Thanks Rahul. That was informative and encouraging. Yes I have contacted the DBA for the earlier post for the error -440. I am proceeding in the direction you have outlined..Thanks.
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 Calling an Open C library function in... CICS 1
No new posts Error while running web tool kit REXX... CLIST & REXX 5
Search our Forums:

Back to Top