Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
DB2 WITH HOLD cursor

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
Author Message
debojyoti

New User


Joined: 11 Jun 2008
Posts: 1
Location: Kolkata

PostPosted: Wed Jun 11, 2008 10:31 pm    Post subject: DB2 WITH HOLD cursor
Reply with quote

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

Global Moderator


Joined: 23 Nov 2006
Posts: 8761
Location: 221 B Baker St

PostPosted: Thu Jun 12, 2008 6:26 am    Post subject:
Reply with quote

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

New User


Joined: 14 Jul 2005
Posts: 44
Location: US

PostPosted: Thu Jun 12, 2008 11:25 pm    Post subject:
Reply with quote

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

Global Moderator


Joined: 14 Mar 2007
Posts: 3183
Location: italy

PostPosted: Thu Jun 12, 2008 11:42 pm    Post subject: Reply to: DB2 WITH HOLD cursor
Reply with quote

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

New User


Joined: 14 Jul 2005
Posts: 44
Location: US

PostPosted: Thu Jun 12, 2008 11:49 pm    Post subject:
Reply with quote

Oops, I missed the part that debojyoti wrote that program A terminates and not the program B.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1