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

What is meant by CURSOR WITH HOLD


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
lmadhavi

New User


Joined: 01 Mar 2006
Posts: 10

PostPosted: Thu Jun 08, 2006 7:24 pm
Reply with quote

can any one of you please explain what is meant by CURSOR WITH HOLD.
and is the purpose of it?
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Fri Jun 09, 2006 2:02 pm
Reply with quote

Hi,


If we declare the cursor with hold option will remain open even if ur program execution is complete.
All locks are released, except locks protecting the current cursor position of open WITH HOLD cursors.
In order to close this cursor u need to explitly close it(Close cursor)

Hope it will helpful
Back to top
View user's profile Send private message
twissi

Active User


Joined: 01 Aug 2005
Posts: 105
Location: Somerset, NJ

PostPosted: Fri Jun 09, 2006 2:56 pm
Reply with quote

HI lmadhavi,

What happens is your CURSOR will get closed when it executes a COMMIT statement and then your program tries to FETCH that CURSOR, you'll get an error "CURSOR in a FETCH or CLOSE statement is not OPEN", SQL = -501.

CURSOR WITH HOLD option is used to get rid of this difficulty.

Hope I'm clear.

Cheers, Twissi.
Back to top
View user's profile Send private message
parikshit123

Active User


Joined: 01 Jul 2005
Posts: 269
Location: India

PostPosted: Fri Jun 09, 2006 4:35 pm
Reply with quote

Hi twissi,

I completely agree with you.

Just to add to that, all cursors opened in the program gets closed and resources are released when program ends. In fact, commit is issued automatically when program ends.

Thanks,
Parikshit
Back to top
View user's profile Send private message
prasadvrk

Active User


Joined: 31 May 2006
Posts: 200
Location: Netherlands

PostPosted: Fri Jun 09, 2006 6:24 pm
Reply with quote

In other words you have to declare a CURSOR with WITHHOLD option if you want to process the rows fetched even after COMMIT(If you dont explicitly COMMIT , COMMIT will be issued after the completion of LUW, Logical Unit Of Work)
Back to top
View user's profile Send private message
twissi

Active User


Joined: 01 Aug 2005
Posts: 105
Location: Somerset, NJ

PostPosted: Fri Jun 09, 2006 7:44 pm
Reply with quote

parikshit123 wrote:
all cursors opened in the program gets closed and resources are released when program ends. In fact, commit is issued automatically when program ends.


Parikshit,

I thought the question was to differentiate between CURSOR & CURSOR WITHHOLD !!

In both the cases what you said (given in quote) will happen for sure!

Does this make sense?

Cheers, Twissi.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Is SQLCODE -811 possible while fetchi... DB2 1
No new posts Restart logic by using cursor name in... DB2 1
No new posts Seeking Resolution for SQKCODE -991 o... DB2 2
No new posts Multiple rows within Cursor when Coun... DB2 14
No new posts Dynamic cursor name in Cobol program COBOL Programming 1
Search our Forums:

Back to Top