Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How to select the last item's ID
David Lee wrote:
>
> I am really sorry about this, but is it possible for you to show me an
> example? Thanks!
>
> "Davide Bianchi" <davidebianchi_at_davidebianchi.net> ¼¶¼g©ó¶l¥ó
> news:9n2jo1$4scm0$1_at_ID-18487.news.dfncis.de...
> > "David Lee" <pritino2020_at_yahoo.com.tw> wrote in message
> > news:9n2i6h$2n5t1$1_at_news.shem.etwebs.com...
> > > After I inserted a row of data, how do I retrieve the
> > > auto-increment ID of this row ?
> >
> > If you are using a SEQUENCE, you just ask for the
> > NEXT value of the sequence and then use that as ID for
> > your table (so, there is no automatic insertion).
> > Otherwise, you can use a Stored Procedure that insert
> > the data and return the generated ID.
> >
> > Davide
> >
> >
> >
insert into my_table values ( x,y,z)
returning the_seq_column
into my_variable;
hth
connor
-- ============================== Connor McDonald http://www.oracledba.co.uk "Some days you're the pigeon, some days you're the statue..."Received on Tue Sep 04 2001 - 16:04:21 CDT