Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id A187B9FB6F4 for ; Sat, 5 May 2007 12:56:48 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 83945-03 for ; Sat, 5 May 2007 12:56:45 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sd.tpf.co.jp (smtp.tpf.co.jp [210.161.239.34]) by postgresql.org (Postfix) with SMTP id DAA599FB6B9 for ; Sat, 5 May 2007 12:56:44 -0300 (ADT) Received: (qmail 25770 invoked from network); 6 May 2007 00:56:42 +0900 X-Authentication: inoue was authenticated by sd.tpf.co.jp at 6 May 2007 00:56:42 +0900 Received: from unknown (HELO ?192.168.11.3?) (219.61.40.6) by sd.tpf.co.jp with SMTP; 6 May 2007 00:56:42 +0900 Message-ID: <463CA938.6020206@tpf.co.jp> Date: Sun, 06 May 2007 00:56:40 +0900 From: Hiroshi Inoue User-Agent: Thunderbird 2.0.0.0 (Windows/20070326) MIME-Version: 1.0 To: Dmitry Samokhin CC: pgsql-odbc@postgresql.org Subject: Re: Replacing IDENTITY with lastval() References: In-Reply-To: Content-Type: text/plain; charset=windows-1251; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/32 X-Sequence-Number: 8945 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