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: locked for update

Re: locked for update

From: <mmellin_at_my-dejanews.com>
Date: Mon, 02 Nov 1998 14:51:18 GMT
Message-ID: <71kgt6$na3$1@nnrp1.dejanews.com>


In article <71evav$1c8q$1_at_whale.gu.net>,   "Alex Buzunov" <sun_at_goldentele.com> wrote:
> Hi, All
>
> Could you pls. tell me how I could check in stored procedure whether a row
> in a table locked for update?
>
> Thanx in advance!
>
> AB
>

Alex, I just figured out a way to implement such a procedure in our application. We have a 3 tier app where the database is static. We have implemented Oracles row level locking as well as using a row version to control who has the latest version of the object.

/* The procedure takes the unique value of the object, the table name, field name, and the rowversion. A dynamic string is built with this information and executed to do a "SELECT FOR UPDATE NOWAIT" If the statement returns a value then the procedure ends and the user still holds the lock so that the application can run an update. If there is a lock on the record from another user Oracle will raise 'ORA-00054: resource busy and acquire with NOWAIT specified' If there is no record returned and there is no lock then the rowversion is incorrect and "(-20010, 'Invalid rowversion')" is raised. */

CREATE OR REPLACE PROCEDURE RESPONSENOW.LOCK_OBJECT

(objectid_in       IN VARCHAR2,
 tablename_in      IN VARCHAR2,
 fieldname_in      IN VARCHAR2,
 rowversion_in     IN INTEGER)
 IS
  select_cursor      INTEGER;
  open_rec           INTEGER := 0;

  BEGIN

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Mon Nov 02 1998 - 08:51:18 CST

Original text of this message

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