Re: Nocount and scope_identity() - Mailing list pgsql-sql

From Tom Lane
Subject Re: Nocount and scope_identity()
Date
Msg-id 23776.1170448113@sss.pgh.pa.us
Whole thread Raw
In response to Re: Nocount and scope_identity()  (Andrew Sullivan <ajs@crankycanuck.ca>)
List pgsql-sql
Andrew Sullivan <ajs@crankycanuck.ca> writes:
> On Fri, Feb 02, 2007 at 01:38:40PM -0600, Demel, Jeff wrote:
>>>> SCOPE_IDENTITY() method is going to work or not.

>>> I doubt it.  What does it do?
>> 
>> It returns the id of the record just inserted.

> Ah.  Well, there's no in-principle notion if "id" in Postgres (OIDs
> are optional as of several versions ago).  But if you have a primary
> key that's an integer you populate using a sequence, then you can use
> the currval() function to get the value of the sequence.

Also, as of 8.2 INSERT RETURNING is a good way to collect the value
of an auto-generated key field (or any other auto-generated field...)
        regards, tom lane


pgsql-sql by date:

Previous
From: Andrew Sullivan
Date:
Subject: Re: Nocount and scope_identity()
Next
From: "Karthikeyan Sundaram"
Date:
Subject: Re: Question regarding multibyte.