View previous topic :: View next topic
|
Author |
Message |
dinesh_deadman Warnings : 1 New User
Joined: 10 Aug 2007 Posts: 32 Location: Chicago
|
|
|
|
Hello,
I have a Prog-A calling Prog-B. Inside this sub-program(Prog-B), I have a cursor and have fetched some values. Now, I want to go back to prog-A and do some processing and come back to Prog-B. When I come back to Prog-B, will the cursor that was opened during last call still be opened or closed?
If closed, is there any other way out for this problem...
If opened, will it point to the same record that it was during last call...
Please help me on this regard.
Thanks,
Dinesh |
|
Back to top |
|
|
stodolas
Active Member
Joined: 13 Jun 2007 Posts: 632 Location: Wisconsin
|
|
|
|
If you are actually returning from B to A and not doing a Call to A from B you will lose and memory that was used in B that wasn't passed back to A. This includes the opened cursor. You could pass some data back to A of where you left off then when you were exiting B. Then when you come back into B reopen the cursor at that point. However there is no guarentee that this new cursor will contain the same data as the previous run into B.
Lose Cursor:
Prog A
Call Prog B
Process Data
Call Prog B
Prog B
Open cursor
return to A
Keep Cursor:
Prog A
Call Prog B
Prob B
Call Prog A
Prog A
Process data |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
If you explain what you need to do in a business sense (rather than how it is currently being implemented technically), someone here may be able to offer suggestions. |
|
Back to top |
|
|
dinesh_deadman Warnings : 1 New User
Joined: 10 Aug 2007 Posts: 32 Location: Chicago
|
|
|
|
Thanks for the reply..... |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
I don't think the OP is complaining about a problem that has occurred. I think he just does not know enough about COBOL.
OP said Pgm-A is CALLing Pgm-B.
As long as Pgm-A does not CANCEL Pgm-B before another CALL to Pgm-B
and Pgm-B does not have an INITIAL statement,
Pgm-B will reenter with the CURSOR where it belongs, as long as Pgm-B has logic to check a flag or two upon entry to determine what, where, how, and why.
Best thing is to set-up Pgm-B to react to function requests instead of too much logic trying to control everything. If Pgm-B is just doing DB2, then if it receives a request to OPEN and FETCH a CURSOR, it should do that. If the function request is to 'FETCH-NEXT' is should just do that and report any negative SQLCODES (or +100). If Pgm-B is too complicated, will be a bear to debug.
This of course talking about Batch. Does not really matter if it is Statically or Dynamically linked. |
|
Back to top |
|
|
|