Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

submodule cursor not being restarted on calling 2nd time

Status
Not open for further replies.

andymc1

Programmer
Jun 28, 2002
23
CH
OK don't know the best way to describe this but here goes...my main module,running in CICS) calls a submodule for every row in an array, the submodule does an open/fetch/close(DB2) on the parm passed by the main module for the search criteria. On calling the submodule greater than once the cursor in the submodule behaves as though it is still the same instance of the program, it does not do a new fetch, in Expediter it jumps straight past the fetch piece of code. I think on the first goback from the submodule it is not releasing the links with DB2, how do I make sure a fresh version of the program is called every time therefore forcing a new cursor? Have tried an EXEC CICS SYNCPOINT but this releases some resources I need to hold...all help much appreciated...
 
There are a few issues here that you could clarify for us.
1. Are there any conditions associated with the Fetch?
2. Was the cursor effectively (no errors) closed, before the Goback?
3. Was the cursor reOpened without any errors, on re-entry?

There are two ways to make sure a new/clean version of the subprogram is executed every time.
1. Make sure the subprogram does not "remember" anything that happened in any previous call. Initialize everything on entry (buffers, condition codes,...), get new values only from the Caller, Open new cursor, etc...
2. Qualify the subprogram as Initial (costlier option).

Dimandja
 
Andy,
Are you closing the cursor at the end of the subroutine? DB2 will keep the same thread in a subroutine, so when you call it again, if you haven't closed the cursor, it will just pick up from where it left off at the end of the last call. In order to make sure that it restarts you will have to close and re-open the cursor.
hth
Marc
 
thanks for the suggestions, found the problem last week, not surprisingly it was my stupid logic which caused the problem ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top