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
 
-502 Error - Cursor already open

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: -502 Error - Cursor already open
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

Senior Member


Joined: 21 Sep 2010
Posts: 1818
Location: NY,USA

PostPosted: Mon Oct 30, 2017 4:28 pm    Post subject:
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: 1922
Location: UK

PostPosted: Mon Oct 30, 2017 5:21 pm    Post subject:
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    Post subject:
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: 1781
Location: Bloomington, IL

PostPosted: Mon Oct 30, 2017 9:42 pm    Post subject:
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: 408
Location: USA

PostPosted: Mon Oct 30, 2017 10:15 pm    Post subject: Reply to: -502 ERROR
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: 408
Location: USA

PostPosted: Tue Oct 31, 2017 2:05 am    Post subject: Reply to: -502 ERROR
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    Post subject: Reply to: -502 ERROR
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    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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts FTP Skip or ignore error and process ... AJAYREDDY All Other Mainframe Topics 3 Wed Sep 27, 2017 8:12 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
No new posts FUSE - IBM MQ - CICS integration error Kevin Vaz CICS 1 Mon Sep 18, 2017 4:31 pm

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