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

Home -> Community -> Usenet -> c.d.o.misc -> Re: how to lock a table?

Re: how to lock a table?

From: John P. Higgins <jh33378nospam_at_deere.com>
Date: 1998/02/13
Message-ID: <34E46E12.30E7@deere.com>#1/1

This sounds like you need to use select ... FOR UPDATE in your cursor. Then you can code:
if found

   update row WHERE CURRENT OF cursor_name else

   insert row

The select ... FOR UPDATE locks the row(s) selected AND allows you to update (or delete) WHERE CURRENT OF cursor_name one FETCH at a time.

Sascha Bohnenkamp wrote:
>
> Helo,
>
> I use pl/sql on oracle7.x and have the following problem:
>
> I want to update a set, if it exists, or else insert it into one table ...
>
> I tried
>
> lock table in exclusive mode
>
> select from that table
> if(exists)
> update table
> else
> insert into table
>
> well it does NOT work, because the lock does NOT lock the select, but
> the update-insert ...
>
> I solved it with something like
> set transaction mode serializable
>
> but this seems to me like a hammer ... what is the REAL solution, please !!!!
  Received on Fri Feb 13 1998 - 00:00:00 CST

Original text of this message

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