Skip site navigation (1) Skip section navigation (2)

Re: Last ID Problem

From: Mitch Pirtle <mitch(dot)pirtle(at)gmail(dot)com>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: operationsengineer1(at)yahoo(dot)com, pgsql-novice(at)postgresql(dot)org
Subject: Re: Last ID Problem
Date: 2005-02-01 01:55:22
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-novice
On Mon, 31 Jan 2005 18:38:55 -0700, Michael Fuhr <mike(at)fuhr(dot)org> wrote:
> Contrary to what another message in this thread says, it is indeed
> common practice to do the insert first and call currval() afterwards
> to find out what value you got from the sequence.  And no, this
> doesn't introduce a race condition -- currval() returns the last
> value obtained from the sequence in the current session.

Tell that to the maintainers of PEAR's DB, which is installed by
default with all recent versions of PHP (that would be all of them). I
felt the exact same way as you did, and spent an afternoon
rediscovering the joys of sequence values until one of the maintainers
pointed out that behavior. I even tried to convince them that this was
a bug ('inappropriate behavior' was the term IIRC)...

'Common', unfortunately, is relative; and in this matter might only
apply to ADOdb ;-)

-- Mitch, getting his PHP database classes all mixed up *gasp*

In response to


pgsql-novice by date

Next:From: Alexander BorkowskiDate: 2005-02-01 02:09:11
Subject: Re: pgAdminIII and User Grants
Previous:From: Mike G.Date: 2005-02-01 01:53:55
Subject: Re: pgAdminIII and User Grants

pgsql-hackers by date

Next:From: Tom LaneDate: 2005-02-01 03:45:08
Subject: Re: [Feed-back] Installing PostgreSQL 8.0.0 on SPARC/Solaris. Configure and install issues.
Previous:From: Michael FuhrDate: 2005-02-01 01:45:55
Subject: Re: Last ID Problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group