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

COBOL-DB2 Will the cursor be opened during second call?


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
dinesh_deadman
Warnings : 1

New User


Joined: 10 Aug 2007
Posts: 32
Location: Chicago

PostPosted: Sat Aug 25, 2007 2:29 am
Reply with quote

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
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Sat Aug 25, 2007 3:06 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Aug 25, 2007 4:16 am
Reply with quote

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
View user's profile Send private message
dinesh_deadman
Warnings : 1

New User


Joined: 10 Aug 2007
Posts: 32
Location: Chicago

PostPosted: Sat Aug 25, 2007 4:25 am
Reply with quote

Thanks for the reply.....
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Sat Aug 25, 2007 4:36 am
Reply with quote

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
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top