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

Re: SQL syntax help

From: <afilonov_at_pro-ns.net>
Date: Sun, 19 Mar 2000 05:39:37 GMT
Message-ID: <8b1p6o$uk7$1@nnrp1.deja.com>


In article <sd5dv3dvfja29_at_corp.supernews.com>, "Ashwath Kakhandiki" <ashwath_at_bluedog.com> wrote:
> 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.
>
>

No way. The only safe way to set unique numeric sequential ids is to use sequences. You might have holes in sequence (in case of rollbacks) but you won't have any duplicates.

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Sat Mar 18 2000 - 23:39:37 CST

Original text of this message

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