Home » SQL & PL/SQL » SQL & PL/SQL » GURUS! What is the best way to lock records (only lock)
GURUS! What is the best way to lock records (only lock) [message #20516] Fri, 31 May 2002 05:48 Go to next message
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 Go to previous messageGo to next message
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!
Re: GURUS! What is the best way to lock records (only lock) [message #20530 is a reply to message #20516] Sun, 02 June 2002 05:18 Go to previous message
Dmitri Lipodat
Messages: 8
Registered: January 2002
Junior Member
I need only lock, no fetch.
Andrew's variant is better.
May be someone know how to do it without cursor?
Previous Topic: Package ?
Next Topic: Re: working with dates
Goto Forum:
  


Current Time: Fri Apr 26 07:14:55 CDT 2024