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: Oracle equival to SQL Server @@IDENTITY

Re: Oracle equival to SQL Server @@IDENTITY

From: Sybrand Bakker <gooiditweg_at_sybrandb.nospam.demon.nl>
Date: Wed, 01 Oct 2003 14:58:07 +0200
Message-ID: <2mjlnv8ckd9cce6pntee65huqu8pqe2nu0@4ax.com>


On Wed, 1 Oct 2003 08:44:10 -0400, "Sean Chang" <sean_at_cnfei.com> wrote:

>Your statement only accomplishes the INSERT part, the OP want the newest ID#
>printed out also: select @@Identity, which is similar to select
>sequence.nextval from dual;

The OP should use the returning clause of the insert statement, provided he is on 8i
>
>Of course, Brian's ( next post) solution will work too, but I don't see
>performance difference
>between : select sequence.nextval from dual VS select sequence.curval from
>dual, please
>enlighten me why my solution slows down performace.
>

extra soft-parse, depending on context (whether called from PL/SQL or standalone) also an extra context-switch. When in SQL*plus also an extra sqlnet roundtrip

>Quota from OP: "But i dont know how can i insert and select in one statement
>!?!?!??!".

By using the returning clause of the insert statement

--
Sybrand Bakker, Senior Oracle DBA
Received on Wed Oct 01 2003 - 07:58:07 CDT

Original text of this message

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