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

Explicit Locks in DB2


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

New User


Joined: 17 Mar 2006
Posts: 26

PostPosted: Fri Mar 17, 2006 10:11 am
Reply with quote

Hi..,
Can any of u explain me how to use explicit locks in DB2 with the syntax.
Back to top
View user's profile Send private message
martin9

Active User


Joined: 01 Mar 2006
Posts: 290
Location: Basel, Switzerland

PostPosted: Fri Mar 17, 2006 6:30 pm
Reply with quote

hy ramp_senti,

Syntax

+------------------------------------------------------------------------+
! !
! >>--LOCK TABLE--table-name-------------------------------------------> !
! +-PARTITION--integer-+ !
! !
! >--IN----SHARE--------MODE------------------------------------------>< !
! +-EXCLUSIVE-+ !
! !
+------------------------------------------------------------------------+

martin9
Back to top
View user's profile Send private message
KS

New User


Joined: 28 Feb 2006
Posts: 91
Location: Chennai

PostPosted: Mon Mar 20, 2006 1:01 pm
Reply with quote

Hi,

Following are the two syntax for LOCK :

1. LOCK TABLE table-name IN SHARE MODE;
ex - LOCK TABLE UPAD.EMPLOYEE IN EXCLUSIVE MODE;

2. LOCK TABLE table-name PART n IN EXCLUSIVE MODE;
ex- LOCK TABLE UPAD.EMPLOYEE PART 1 IN EXCLUSIVE MODE;
When the statement is executed, DB2 locks partition 1 with an X lock. The
lock has no effect on locks that already exist on other partitions in the
table space.

Thanks,
KS
Back to top
View user's profile Send private message
ramp_senti

New User


Joined: 17 Mar 2006
Posts: 26

PostPosted: Tue Mar 21, 2006 10:53 am
Reply with quote

Thanks Martin & KS..

How long will the lock be valid..i mean will it be released once the program gets over or do we have to release it explicitly...
Back to top
View user's profile Send private message
KS

New User


Joined: 28 Feb 2006
Posts: 91
Location: Chennai

PostPosted: Thu Mar 23, 2006 1:03 pm
Reply with quote

I think locks are held until commit or rollback.
Correct if am wrong.
Thanks,
KS
Back to top
View user's profile Send private message
ramp_senti

New User


Joined: 17 Mar 2006
Posts: 26

PostPosted: Fri Mar 24, 2006 1:41 pm
Reply with quote

Hai KS..,
It seems that the lock gets released only when the program ends...i tried to run a select query on the same table which is locked by another program..but the select query is performed only when the program which has locked the table ends....


Okay then any info abt explicit row level locking...
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 Finding locks on z/OS DB2? DB2 2
No new posts How to get the explicit GDG name in t... All Other Mainframe Topics 4
No new posts Explicit Commit DB2 2
No new posts Locks cant be obtained on? Mainframe Interview Questions 1
No new posts Locks on Views DB2 2
Search our Forums:

Back to Top