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
 
Need to close cursor in a called program from calling progra

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Keanehelp

New User


Joined: 27 May 2008
Posts: 71
Location: USA, CA.

PostPosted: Mon Oct 11, 2010 9:59 pm    Post subject: Need to close cursor in a called program from calling progra
Reply with quote

Hi,

I am calling a subroutine statically. There is a cursor which opens in the subroutine.

Is there any way through which I can close that cursor from main program?

Also Please note that I can not use IS INITIAL. Will COMMIT work in such a case?

Please let me know if not clear, i'll provide more details.

Thanks

Nitin
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6970
Location: porcelain throne

PostPosted: Mon Oct 11, 2010 10:31 pm    Post subject:
Reply with quote

cursor names are qualified by the module name.
you can have two modules with the same cursor name - but they are different cursors.

declare/open/fetch/close CURSOR has to be in same module.

normally, when the sql code for a fetch = +100 (or any non-zero)
you issue the CLOSE CURSOR.
So, a CALL to the subroutine for a fetch
would return no rows to the CALLing module
if the sqlcode for the fetch <> 0
and the CALLed submodule would have issued a close cursor,

thus no need to CLOSE Cursor from main/CALLing module.

and yes, a COMMIT issued from the main module
(actually any module in the Batch rununit)
would CLOSE any Cursor opened by any module in the run-unit
that has not been OPENed WITH HOLD.
Back to top
View user's profile Send private message
Keanehelp

New User


Joined: 27 May 2008
Posts: 71
Location: USA, CA.

PostPosted: Tue Oct 12, 2010 9:57 am    Post subject:
Reply with quote

Thanks for your answer DBZ. Appreciated.
Back to top
View user's profile Send private message
Keanehelp

New User


Joined: 27 May 2008
Posts: 71
Location: USA, CA.

PostPosted: Tue Oct 12, 2010 10:38 am    Post subject:
Reply with quote

Hi,

One more question. Does CANCEL statement will close the cursors in subroutine or it will just refresh the variables?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6970
Location: porcelain throne

PostPosted: Tue Oct 12, 2010 1:38 pm    Post subject:
Reply with quote

honestly, do not know, but will make a guess:

Since a CANCEL in just a load module 'unload',
I would say no.

There would be no communication to db2
- a run unit ending, the op-sys communicates with db2
and any db2 associated with the run-unit (task) is terminated.
But a module CANCEL would not cause this communication to be established.

You would in effect have an open cursor that you can never explicitly close,
or access via fetch.

also, even read only cursors should be COMMITed.

Until the run-unit ends, you are going to have problems.

why CANCEL a module that you will CALL again?

and a CANCEL does not refresh anything.
what you probably mean by refreshing variables
would be accomplished via the CALL which would LOAD the module.
Back to top
View user's profile Send private message
anand jeyapaul

New User


Joined: 26 Oct 2017
Posts: 12
Location: india

PostPosted: Wed Nov 01, 2017 3:16 am    Post subject:
Reply with quote

Dick,

I have a question here. If a cursor in the calling program is declared with hold option how do I close it in the called program

Regards

Anand.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2002
Location: UK

PostPosted: Wed Nov 01, 2017 3:55 pm    Post subject:
Reply with quote

7 year old topic - closed
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies.    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 How to display offset thru cobol prog... tvinodkumar7 CICS 1 Sun Apr 22, 2018 8:42 pm
No new posts How do you attach a DB2 plan to a CIC... John Poulakos DB2 0 Wed Apr 18, 2018 1:49 am
No new posts Handling result sets in the calling N... Rusikesh DB2 7 Fri Apr 13, 2018 12:25 am
No new posts VSAM file NOT Found error while proce... SumaReva CICS 5 Wed Apr 11, 2018 9:54 pm
No new posts Mantis Program Compiled? luis carlos CICS 2 Sat Apr 07, 2018 8:59 pm

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