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

Cursor with 'WITH HOLD'


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

New User


Joined: 28 Nov 2006
Posts: 69
Location: India

PostPosted: Thu Nov 01, 2007 2:21 pm
Reply with quote

I have seen many posts for this topic and have searched a bit but have one question about the 'lock' ...............

I am using cursor with 'WITH HOLD' option, and depending upon a indicator field,have a logic to either update the fetched row or insert a new row in table, this is performed in loop .........
So there are 3 possibilities,
a. fetch the row and no action is taken ......
b. fetch the row and update the row
c. fetch the row and insert a new row

if the isolation level is => Cursor stability =>
Following should be true ...........

1. The rows for which no action is taken should be available to other transaction (or program ...whatever) as cursor moves to next row
These will be locked only when that particular row is fetched.

2. The rows which are updated or the new rows inserted will NOT be available and will be locked until "COMMIT" or end of the job.

If this is true .............. then if i am using cursor WITH HOLD, and there are total 10,000 rows to be processed .....
I have a logic to perform COMMIT after every 1000 rows.
After the first 1000 rows will the locks on these 1000 rows be released or the "WITH HOLD" option will hold the locks until the end of Job ???
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Nov 01, 2007 3:07 pm
Reply with quote

suggest you read the manual to understand what 'WITH HOLD' means.

stop guessing.
Back to top
View user's profile Send private message
revel

Active User


Joined: 05 Apr 2005
Posts: 135
Location: Bangalore/Chennai-INDIA

PostPosted: Thu Nov 01, 2007 4:49 pm
Reply with quote

hsk wrote:
if i am using cursor WITH HOLD, and there are total 10,000 rows to be processed .....
I have a logic to perform COMMIT after every 1000 rows.
After the first 1000 rows will the locks on these 1000 rows be released or the "WITH HOLD" option will hold the locks until the end of Job ???


hsk,

According my knowledge, The locks on 1000 rows will be released because the concept behind WITH HOLD is keep open cursor option even though COMMIT or ROLLBACK operation will be imposed
<internally WITHHOLD position will repositioned to previous read records that is the record which comes after COMMIT operation>
---------------------------------------------------------------------
WITH HOLD option is not related to LOCKS

Regards,
Raghavendra
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Inserting into table while open selec... DB2 1
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
Search our Forums:


Back to Top