Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to get the last insert id

Re: How to get the last insert id

From: DA Morgan <damorgan_at_psoug.org>
Date: Sun, 09 Sep 2007 09:54:19 -0700
Message-ID: <1189356851.211985@bubbleator.drizzle.com>


Frank van Bortel wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Norbert Pürringer wrote:

>> Hello once more!
>>
>> If I use a sequence, it's of course no problem to get the ID of the last
>> inserted dataset. But imagine, that the primary key consists of GUID values
>> and the default value of the primary key column is New_Guid. So a new
>> dataset will produce a new GUID value which I want to use in the next
>> statement. But how?
>>
>> You must consider, that I work with the database via ADO.NET. After updating
>> the new dataset, reading out the value of the GUID primary key results to
>> DBNull instead of giving me the new GUID value. So I think the only way is
>> to execute another SQL statement retrieving me the new value. Other database
>> systems provide SQL functions like Scope_Idendity or LastInsertID.
>>
>> Kind regards,
>> Norbert
>>
>>
> Lookup INSERT INTO ... RETURNING
> http://tahiti.oracle.com.
> 
> Without doubt, Daniel has some examples in his library, too,
> but only 11.0, of course :)
> But you'll get the idea
> - --
> Regards,
> Frank van Bortel

When I mark something in the library 11g that indicates I have tested it in 11g and it is functional and supported. If the functionality exists in previous versions it will work there too.

In the case of the RETURNING clause it goes back many versions.

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu (replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Received on Sun Sep 09 2007 - 11:54:19 CDT

Original text of this message

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