pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Sullivan <ajs@crankycanuck.ca>
Cc: pgsql-sql@postgresql.org, "Demel, Jeff" <Jeff.Demel@JavelinDirect.com>
Subject: Re: Nocount and scope_identity()
Date: Fri, 02 Feb 2007 15:28:33 -0500
Message-ID: <23776.1170448113@sss.pgh.pa.us> (raw)
In-Reply-To: <20070202195729.GJ11505@phlogiston.dyndns.org>
References: <136ED738BD4F1545B97E4AC06FF6370734C25C@DMSP-MSG-EVS01.mail.pvt>
	<20070202195729.GJ11505@phlogiston.dyndns.org>

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



view thread (5+ messages)

Message-ID: <23776.1170448113@sss.pgh.pa.us>
Permalink:  ../23776.1170448113@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/23776.1170448113@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ajs@crankycanuck.ca, Jeff.Demel@JavelinDirect.com
  Subject: Re: Nocount and scope_identity()
  In-Reply-To: <23776.1170448113@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox