Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: newbe concurrency question
A copy of this was sent to "Justin Call" <justin_at_thoughtstar.com>
(if that email address didn't require changing)
On Mon, 2 Aug 1999 13:28:49 -0600, you wrote:
>All-
>
>Lets say that I have several webservers running servlets using JDBC to
>connect to an oracle database (8i for example). If I repeatedly execute the
>following on all "clients":
>
>INSERT INTO SOMETABLE (SOMEINTCOLUMN) VALUES (SELECT FROM SOMETABLE
>MAX(SOMEINTCOLUMN));
>
>Do I ever duplicate values in SOMECOLUMN?
absolutely you will.
Unless you have a primary key (or unique) constraint on SOMEINTCOLUMN -- then everyone will wait in line and some people will succeed and some will perhaps fail.
You might consider looking at sequences and instead:
insert into sometable ( someintcolumn ) values ( your_sequence.nextval );
> If so, is the same true if the
>database is replicated using parallel server?
>
OPS is not a replication implementation. Its a single copy of a database opened by many instances on different machines. it would see the same things as above. again, a sequence would be the best way to do this.
>Any help would be much appreciated!
>
>-Justin
>
>
>
--
See http://govt.us.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'...
Current article is "Part I of V, Autonomous Transactions" updated June 21'st
Thomas Kyte tkyte_at_us.oracle.com Oracle Service Industries Reston, VA USA
Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Sun Aug 08 1999 - 09:37:33 CDT