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: saving object using sequence as ID, help!

Re: saving object using sequence as ID, help!

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Sat, 6 Apr 2002 08:16:13 +0200
Message-ID: <uat5r3m435h7ed@corp.supernews.com>

"Henry" <hxzhang_at_binary-solutions.net> wrote in message news:RApr8.13573$226.639285_at_news2.telusplanet.net...
> From: "Henry" <hxzhang_at_binary-solutions.net>
> Subject: saving object into database with sequence as ID, help please!
> Date: Friday, April 05, 2002 2:42 PM
>
> I have a table with each row corresponds to a javabean object. The objects
> don't
> necessarily have a primary key, so i use a sequence number as its primary
> key, and a
> trigger to assign the sequence number to its ID column when a new object
is
> inserted
> into the database.
>
> However, after I insert the object into the table, how can i know the
> object's ID in the
> table? If I simply do a "..._seq.cur_val", it is not safe when multiple
> users can access
> the database and save their javabean into it at the same time.
>
> How could you guys accomplish that?
>
>
>
>

assuming 8i or higher (gee, why do posters NEVER mention their version) you could use the returning clause of the insert statement.

Regards

--
Sybrand Bakker
Senior Oracle DBA

to reply remove '-verwijderdit' from my e-mail address
Received on Sat Apr 06 2002 - 00:16:13 CST

Original text of this message

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