Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 890AF9FA22A for ; Fri, 2 Feb 2007 15:57:44 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 35659-08 for ; Fri, 2 Feb 2007 15:57:36 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from main2.mycybernet.net (main2.mycybernet.net [209.222.63.140]) by postgresql.org (Postfix) with ESMTP id E320D9FA1BB for ; Fri, 2 Feb 2007 15:57:35 -0400 (AST) Received: from 227-54-222-209.mycybernet.net ([209.222.54.227] helo=phlogiston.dydns.org) by main2.mycybernet.net with esmtp (Exim 4.62) (envelope-from ) id 1HD4ii-0006PM-LM for pgsql-sql@postgresql.org; Fri, 02 Feb 2007 15:09:16 -0500 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 518364051; Fri, 2 Feb 2007 14:57:29 -0500 (EST) Date: Fri, 2 Feb 2007 14:57:29 -0500 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: Nocount and scope_identity() Message-ID: <20070202195729.GJ11505@phlogiston.dyndns.org> References: <136ED738BD4F1545B97E4AC06FF6370734C25C@DMSP-MSG-EVS01.mail.pvt> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <136ED738BD4F1545B97E4AC06FF6370734C25C@DMSP-MSG-EVS01.mail.pvt> User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/26 X-Sequence-Number: 27360 On Fri, Feb 02, 2007 at 01:38:40PM -0600, Demel, Jeff wrote: > Not as far as I know. What's it supposed to do? > > It suppresses the rowcount returned after the query runs. There isn't a way to do that, although there is a way in psql, for example, not to get all that formatting. You want the \pset commands. The count isn't automatically delivered with most APIs (i.e. if you want to know how many rows you touched, you usually have to ask explicitly). > > 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. There's no race condition there unless you are sharing a pooled connection (and if transactions mean anything to you, you'd better not be doing). A -- Andrew Sullivan | ajs@crankycanuck.ca The fact that technology doesn't work is no bar to success in the marketplace. --Philip Greenspun