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: Sean Chang <sean_at_cnfei.com>
Date: Wed, 1 Oct 2003 08:44:10 -0400
Message-ID: <3f7acca1$1_3@corp.newsgroups.com>

"Daniel Morgan" <damorgan_at_x.washington.edu> wrote in message news:1064957226.280315_at_yasure...
> Sean Chang wrote:
>
> >I believe you will need 2 statements to accomplish the Insert and select:
> >
> >Declare
> >Next_Num Number(8);
> >
> >begin
> >
> >select Your_Sequence.nextval into Next_Num from dual;
> >insert into SG_MENUE (LevelName, ErstelltAm, ID#) VALUES ('Neuer bere',
> >'10.10.2003',Next_Num);
> >------
> >end;
> >/
> >
> >then you can return Next_Num as the newest ID# for further use.
> >
> >Hope this helps.
> >
> ><snipped>
> >
> Surely you jest. I wrote this before and I will do it again:
>
> insert into SG_MENUE (LevelName, ErstelltAm, ID#) VALUES ('Neuer bere',
> '10.10.2003',your_sequence.NEXTVAL);
>
> What you suggest accomplishes nothing except to slow down performance.

Hi, Daniel,

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;

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.

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

Sean Chang

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 100,000 Newsgroups - 19 Different Servers! =----- Received on Wed Oct 01 2003 - 07:44:10 CDT

Original text of this message

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