SELECT @@IDENTITY

From: "Robert J(dot) Sanford, Jr(dot)" <rsanford(at)trefs(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: SELECT @@IDENTITY
Date: 2003-06-23 17:58:34
Message-ID: 002501c339b1$114253e0$67010a0a@nls.nlsholdings.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Okay, I did a quick search through both the general and SQL lists(1,2)
trying to determine if there is a PostgreSQL construct equivalent to
Microsoft SQL Server's "SELECT @@IDENTITY". After performing an insert the
database caches the last sequence number for each connection and the select
retrieves that value. Thus if connection A and connection B each inserted
into the same table they would each know what the value of the sequence was
immediately after their insert.

Is there any direct support for this? I know that I can manually code to
select the nextval of a sequence but the syntactic sugar of SELECT
@@IDENTITY is really nice.

Many thanks!

rjsjr

1 - The only valid query I could find was
http://archives.postgresql.org/pgsql-general/2001-09/msg00523.php which is
unanswered.
2 - The search engine for the archives seems to ignore the "@@" in the
search string so I ended up with a LOT of information on corporate identity
and identity columns.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dennis Gearon 2003-06-23 18:07:41 Re: [GENERAL] interesting PHP/MySQL thread
Previous Message Tom Lane 2003-06-23 17:44:53 Re: A creepy story about dates. How to prevent it?