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

Cursor Locking and Lock Size


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

New User


Joined: 27 Mar 2008
Posts: 8
Location: INDIA

PostPosted: Fri Apr 04, 2008 1:47 pm
Reply with quote

I have coded a simple cursor which can extract millions of rows.
And the isolation was specified as CS.

Query1 : When the locks would be applied ?
a) During Open
b) During Fetch
Query2 : What is the Size of the lock?
a) All quallified millions of rows ( Which can be escalated to Table Space Lock)
b) Only a Page (4K) will be locked.
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Fri Apr 04, 2008 2:34 pm
Reply with quote

Please visit this topic.
ibmmainframes.com/viewtopic.php?t=29412
Back to top
View user's profile Send private message
deepananda

New User


Joined: 27 Mar 2008
Posts: 8
Location: INDIA

PostPosted: Fri Apr 04, 2008 3:02 pm
Reply with quote

Actually, the topic was started by one of my colleague. Still it wasn't clear on the Lock Size and we have some problem in production regading this.

Your feedback would be appreciated.
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Fri Apr 04, 2008 3:18 pm
Reply with quote

If you have seen at manual...

Cursor Stability (CS) locks any row accessed by a transaction of an application while the cursor is positioned on the row. This lock remains in effect until the next row is fetched or the transaction is terminated. However, if any data on a row is changed, the lock must be held until the change is committed to the database.

Recalling the example of scanning 10 000 rows, if you use Cursor Stability, you will only have a lock on the row under your current cursor position. The lock is removed when you move off that row (unless you update that row).

If anything else, please be specific with your question so that someone would reply you clearly...
Back to top
View user's profile Send private message
deepananda

New User


Joined: 27 Mar 2008
Posts: 8
Location: INDIA

PostPosted: Fri Apr 04, 2008 3:26 pm
Reply with quote

Thanks
Back to top
View user's profile Send private message
Prajesh_v_p

Active User


Joined: 24 May 2006
Posts: 133
Location: India

PostPosted: Fri Apr 04, 2008 6:01 pm
Reply with quote

Query1 : When the locks would be applied ?

a) During Open -: If your cursor query causes a datasort and fetch reads records from sort out file. It wont cause a row level lock even if you bind with CS, during a fetch

b) During Fetch -: If your SQL is not causing any sorts, then things will be exactly as what Gnanas said, unless and untill you specify the isolation level in your cursor.

This is what my understanding is. Please correct me if I am wrong.

Thanks,
Prajesh
Back to top
View user's profile Send private message
deepananda

New User


Joined: 27 Mar 2008
Posts: 8
Location: INDIA

PostPosted: Tue Apr 08, 2008 3:05 pm
Reply with quote

Thanks a lot
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 -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Lock Escalation DB2 3
No new posts Using Java/C/C++ to retrieve dataset ... Java & MQSeries 6
No new posts Find the size of a PS file before rea... COBOL Programming 13
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
No new posts Dataset size increase on adding 1 byt... DFSORT/ICETOOL 8
Search our Forums:

Back to Top