pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Hiroshi Inoue <inoue@tpf.co.jp>
To: Dmitry Samokhin <sdld@mail.ru>
Cc: pgsql-odbc@postgresql.org
Subject: Re: Replacing IDENTITY with lastval()
Date: Sun, 06 May 2007 00:56:40 +0900
Message-ID: <463CA938.6020206@tpf.co.jp> (raw)
In-Reply-To: <E1HjwBJ-000Hnc-00.sdld-mail-ru@f105.mail.ru>
References: <E1HjwBJ-000Hnc-00.sdld-mail-ru@f105.mail.ru>

Dmitry Samokhin wrote:
> Accordind to the release notes, "Use lastval() function to replace IDENTITY on 8.1 or later servers" was introduced in release 8.2.0205. This may cause incorrect results: "<...> assumes that your database does not expect any triggers to fire when the INSERT is executed. If a trigger does fire and if that trigger adds another row to a table, the @@IDENTITY global variable would be set to point to that new Identity value—not the one your INSERT generated. <...> work for simple situations, but not when your database gets more sophisticated".
> See "Managing an @@IDENTITY Crisis" on MSDN (http://msdn2.microsoft.com/en-us/library/ms971502.aspx) for more details.
> 
> The PostgreSQL documentation states that the lastval() function returns the value most recently returned by nextval in the current session. It works the same way as the @@IDENTITY variable in MSSQL. The currval(...) function returns a value of the explicitly specified sequence, this is exactly what we need.
> 
> Please consider to revert the code.

OK I would take care of it in 8.2.0402.

regards,
Hiroshi Inoue



view thread (5+ messages)  latest in thread

Message-ID: <463CA938.6020206@tpf.co.jp>
Permalink:  ../463CA938.6020206@tpf.co.jp/
Also on:    postgresql.org/message-id/463CA938.6020206@tpf.co.jp

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: inoue@tpf.co.jp, sdld@mail.ru
  Subject: Re: Replacing IDENTITY with lastval()
  In-Reply-To: <463CA938.6020206@tpf.co.jp>
  References: <E1HjwBJ-000Hnc-00.sdld-mail-ru@f105.mail.ru> <463CA938.6020206@tpf.co.jp>

* 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