Re: Nocount and scope_identity()

From: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Nocount and scope_identity()
Date: 2007-02-02 19:57:29
Message-ID: 20070202195729.GJ11505@phlogiston.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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(at)crankycanuck(dot)ca
The fact that technology doesn't work is no bar to success in the marketplace.
--Philip Greenspun

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2007-02-02 20:28:33 Re: Nocount and scope_identity()
Previous Message Karthikeyan Sundaram 2007-02-02 19:51:50 Question regarding multibyte.