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: Getting primary key right after insertion into the record

Re: Getting primary key right after insertion into the record

From: Darwin Ling <dling_at_one-umbrella.com>
Date: Fri, 15 Sep 2000 12:33:33 -0500
Message-ID: <8ptm4f$jo0$1@news.jump.net>

I am using Oracle 8i.

I don't quite understand what you mean by the returning clause. I just called statement.executeUpdate("insert....");

And the returning type of this executeUpdate is the number of rows affected.

Please clarify. Thanks

"Sybrand Bakker" <postbus_at_sybrandb.demon.nl> wrote in message news:969035331.1629.0.pluto.d4ee154e_at_news.demon.nl...
> There's no need to do it that way.
> In Oracle 8.0 and before you can simply select <sequencename>.nextval into
> <anyvariable>
> before you do the insert
> In Oracle 8i and beyond you can use the returning clause of the insert
> command.
>
> Hth,
>
> Sybrand Bakker, Oracle DBA
>
> "Jump.Net" <darwin_ling_at_hotmail.com> wrote in message
> news:8ptego$92m$1_at_news.jump.net...
> > How do I obtain the primary key ID right after a record is inserted in
> > Oracle?
> >
> > Such primary key is generated by trigger/sequence. And I am doing it
 within
> > a Java JDBC environment
> >
> > And this has to work in a multithreaded environment.
> >
> > I thought about using
> >
> > select max(id) from table
> >
> > right after the insert.
> >
> > Would this be the best way?
> >
> >
>
>
Received on Fri Sep 15 2000 - 12:33:33 CDT

Original text of this message

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