Re: getting back autonumber just inserted

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: PFC <lists(at)boutiquenumerique(dot)com>
Cc: Michael Fuhr <mike(at)fuhr(dot)org>, lmeadors(at)apache(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: getting back autonumber just inserted
Date: 2005-07-07 22:42:27
Message-ID: 20050707224227.GB23230@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Fri, Jul 08, 2005 at 12:26:30AM +0200, PFC wrote:
>
> >That's a different issue than whether currval() is subject to
> >interference from other transactions. And just wait until PostgreSQL
> >8.1 comes out and people start using lastval() -- then it could get
> >*really* confusing which sequence value you're getting.
>
> What happens if an INSERT trigger inserts something into another
> table which also has a sequence ?

Using what, lastval()? The app will get very confused, because it'll
get the value from the sequence used in the trigger. Using currval
there is no problem, but you already knew that.

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
"Hay quien adquiere la mala costumbre de ser infeliz" (M. A. Evans)

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Fuhr 2005-07-07 22:44:52 Re: getting back autonumber just inserted
Previous Message PFC 2005-07-07 22:26:30 Re: getting back autonumber just inserted