Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Need to close cursor in a called program from calling progra

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Keanehelp

New User


Joined: 27 May 2008
Posts: 70
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: 6966
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: 70
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: 70
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: 6966
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
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 Getting -504 Cursor Name GTT-ARTS-CUR... Robin Sulsona DB2 2 Fri Mar 17, 2017 1:43 am
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Release of Adabas Cursor mohitsethi All Other Mainframe Topics 1 Mon Feb 06, 2017 8:36 pm
No new posts Calling procedure with multiple entri... steve-myers PL/I & Assembler 5 Fri Jan 27, 2017 3:33 pm
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us