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: sql syntax help

Re: sql syntax help

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: 2000/03/18
Message-ID: <953335758.1684.0.pluto.d4ee154e@news.demon.nl>#1/1

Better use an Oracle sequence.
If you still want to use this approach make sure you issue select id+1 from table for update of id. Then you will be certain id doesn't change between the select and the update.

Hth,
Sybrand Bakker, Oracle DBA

Ashwath Kakhandiki <ashwath_at_bluedog.com> wrote in message news:sd5e13gtfja96_at_corp.supernews.com...
> Hi everyone,
>
> I have two SQL query statements like this:
>
> SELECT ID FROM ID_TABLE
>
> set variable id = ID in Java code
>
> UPDATE ID_TABLE SET ID= "+ (id+1) + " WHERE ID=" + (id);
>
> Is there a safe way to do this so that it will succeed
>
> for all callers? It is supposed to return a unique,
>
> increasing number every time it's called.
>
>
>
Received on Sat Mar 18 2000 - 00:00:00 CST

Original text of this message

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