Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: PL/SQL AND LOCK
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