Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: How to lock a row when the row is not is accessed

Re: How to lock a row when the row is not is accessed

From: Billy <vslabs_at_onwe.co.za>
Date: 16 Jun 2005 04:02:11 -0700
Message-ID: <1118918696.315901.55010@o13g2000cwo.googlegroups.com>


li.js_at_neusoft.com wrote:
> I want to lock some rows in a table, but I must know these rows are not
> accessed(SELECT/UPDATE) by other sessions.
>
> How to know the row is used by other sessions.

SELECT .. FOR UPDATE NOWAIT This will select the rows and lock them for UPDATE - but should they already be locked the SELECT statement will raise an exception.

Or you can add the WAIT clause with the number of seconds to wait for the rows to be unlocked (i.e. available for updating) before timing out.

Also note that locking rows does not block readers - other sessions can still read the rows as per Oracle MVCC (Multi Version Concurrency Control) model.

You can also skip locked rows using the SKIP LOCKED clause.

--
Billy
Received on Thu Jun 16 2005 - 06:02:11 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US