Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 57F339FA344 for ; Fri, 2 Feb 2007 16:28:49 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 06558-02 for ; Fri, 2 Feb 2007 16:28:46 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 7F1349FA2BB for ; Fri, 2 Feb 2007 16:28:46 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id l12KSXRX023777; Fri, 2 Feb 2007 15:28:33 -0500 (EST) To: Andrew Sullivan cc: pgsql-sql@postgresql.org, "Demel, Jeff" Subject: Re: Nocount and scope_identity() In-reply-to: <20070202195729.GJ11505@phlogiston.dyndns.org> References: <136ED738BD4F1545B97E4AC06FF6370734C25C@DMSP-MSG-EVS01.mail.pvt> <20070202195729.GJ11505@phlogiston.dyndns.org> Comments: In-reply-to Andrew Sullivan message dated "Fri, 02 Feb 2007 14:57:29 -0500" Date: Fri, 02 Feb 2007 15:28:33 -0500 Message-ID: <23776.1170448113@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/27 X-Sequence-Number: 27361 Andrew Sullivan 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