Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: sql syntax help
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