Re: Nocount and scope_identity()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
Cc: pgsql-sql(at)postgresql(dot)org, "Demel, Jeff" <Jeff(dot)Demel(at)JavelinDirect(dot)com>
Subject: Re: Nocount and scope_identity()
Date: 2007-02-02 20:28:33
Message-ID: 23776.1170448113@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Andrew Sullivan <ajs(at)crankycanuck(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Karthikeyan Sundaram 2007-02-04 21:34:41 Re: [SQL] Question regarding multibyte.
Previous Message Andrew Sullivan 2007-02-02 19:57:29 Re: Nocount and scope_identity()