If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Table Locking Not Working

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-10-06, 04:46
Griffith Griffith is offline
Registered User
 
Join Date: Jan 2006
Posts: 7
Table Locking Not Working

Hi there,

I am using DB2 7.1 and I am trying to lock a table in exclusive mode with the following command:

lock table sequence_number in exclusive mode

The command completes successfully.

I am under the assumption that this should prevent any reads (except UR) from the sequence_number table. However I am still able to execute a select statement from another transaction with the command:

select * FROM sequence_number with RR

Am I missing something obvious here?


Thank you and best wishes,
Reply With Quote
  #2 (permalink)  
Old 01-10-06, 05:47
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
LOCK TABLE statement holds the lock until the next commit. If your LOCK TABLE session had autocommit, then the lock would have been released.

Issue
db2 +c lock table sequence_number in exclusive mode

Issue your select statement in the other window and now it should work !!!
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 01-12-06, 01:52
Griffith Griffith is offline
Registered User
 
Join Date: Jan 2006
Posts: 7
Great, thanks allot - it works well now


Best wishes,
Reply With Quote
  #4 (permalink)  
Old 01-12-06, 03:54
gardenman gardenman is offline
Registered User
 
Join Date: Apr 2004
Posts: 54
as well you can change autocommit dynamicly in your script:

--disable autocommit
update command options using c off@
lock table mytable in exclussive mode@
update...
delete...
insert...
commit@
-- switch to autocommit
update command options using c on@
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On