GURUS! What is the best way to lock records (only lock) [message #20516] |
Fri, 31 May 2002 05:48 |
Dmitri Lipodat
Messages: 8 Registered: January 2002
|
Junior Member |
|
|
I want to lock some existed records in a table. But:
1) I don't want to update something.
2) I don't want ot fetch something.
3) I don't want to lock full table.
I want only make lock of some records.
Variants:
1) for dummy_cursor in (select * f.... for update) loop null; end loop;
2) update myTable set myCol = myCol where ....
3) Others....
Which one is better?
|
|
|
Re: GURUS! What is the best way to lock records (only lock) [message #20523 is a reply to message #20516] |
Fri, 31 May 2002 11:21 |
andrew again
Messages: 2577 Registered: March 2000
|
Senior Member |
|
|
I haven't tested, but I'm pretty sure that Opening the cursor locks the rows, so there should be no reason to loop - you could exit on the first itteration. That's just nitpicking.
You could also just declare an explicit cursor, open it and then carry on. (no need for a loop structure).
Commit/rollback will release the locks. Remember to index foreign keys -- else you'll lock the whole child table if you have them!
|
|
|
|