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

Home -> Community -> Usenet -> c.d.o.tools -> Re: PL/SQL AND LOCK

Re: PL/SQL AND LOCK

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 1997/09/10
Message-ID: <34191360.9790728@newshost>#1/1

On Wed, 10 Sep 1997 15:03:32 +0200, Matteo Lonardi <teo_at_romeo.sci.univr.it> wrote:

>I have to lock only one record (or a set of record) in PL/SQL.
>I have tried to use a cursor FOR UPDATE but it doesn't seem to work.
>

why doesn't it seem to work, the following works:

create or replace procedure for_update
as

    cursor c1 is select * from scott.emp for update; begin

    for x in c1 loop

        dbms_output.put_line( x.ename );     end loop;
end;
/

it looks all of the rows in the emp table (put a where clause on to lock only certain rows). Run this in one session, don't commit, goto another window and start a new database session and try to update the emp table, it'll block until you commit this first session.

>Does anybody know how can I be able to do it?
>
>Thanks in advance.
>
>Matteo Lonardi
>teo_at_romeo.sci.univr.it

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Bethesda MD

http://govt.us.oracle.com/ -- downloadable utilities



Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Wed Sep 10 1997 - 00:00:00 CDT

Original text of this message

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