|
|
| Author |
Message |
debojyoti
New User
Joined: 11 Jun 2008 Posts: 1 Location: Kolkata
|
|
|
|
Hi, I need a help to a problem I am facing.
I have a Program A that calls a program B. In program B, I have declared a cursor WITH HOLD on a DB2 table. Now, each time A calls B, a row is fetched from the cursor and returned to pgm A. Now, if program A terminates without closing the cursor in program B, will the cursor be closed automatically. or it will remain open.
After the program exits, is there any way to check if the cursor was closed, or is it still in open state? |
|
| Back to top |
|
 |
References
|
Posted: Wed Jun 11, 2008 10:31 pm Post subject: Re: DB2 WITH HOLD cursor |
 |
|
|
 |
dick scherrer
Global Moderator
Joined: 23 Nov 2006 Posts: 7518 Location: 221 B Baker St
|
|
|
|
Hello debojyoti and welcome to the forums,
| Quote: |
| Now, if program A terminates without closing the cursor in program B, will the cursor be closed automatically. or it will remain open. |
When programA terminates, the cursor will no longer exist and any holds will be released. This would happen whether the cursor was used in programA or programB. When A terminates, the resources for that run unit are released. |
|
| Back to top |
|
 |
anv2005
New User
Joined: 14 Jul 2005 Posts: 44 Location: US
|
|
|
|
I respectfully disagree.
Many shops utilize what they call a SQL driver program. This is a sub-program that contains all their SQL statements. Such sub-program is called by many callers and may OPEN, FETCH and CLOSE cursor(s) SQL statements among any other SQL requests.
IBM LE does not destroy any resources held by a COBOL sub-program if the sub-program returns control to its caller via the GOBACK construct, unless the sub-program is placed into initial state via the INITIAL keyword of the PROGRAM ID. paragraph. |
|
| Back to top |
|
 |
enrico-sorichetti
Global Moderator
Joined: 14 Mar 2007 Posts: 2562 Location: italy
|
|
|
|
| Quote: |
| respectfully disagree. |
You' d better change Your mind,
when program A terminates, control will return to db2..
I.E to the RUN command/subcommand which will carry on all the termination houskeeping, closing cursor, committing all the changes |
|
| Back to top |
|
 |
anv2005
New User
Joined: 14 Jul 2005 Posts: 44 Location: US
|
|
|
|
| Oops, I missed the part that debojyoti wrote that program A terminates and not the program B. |
|
| Back to top |
|
 |
|
|