From: | Michael Fork <mfork(at)toledolink(dot)com> |
---|---|
To: | Gregory Wood <gregw(at)com-stock(dot)com> |
Cc: | Kostis Mentzelos <mentzelos(at)ematic(dot)com>, PostgreSQL-General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Re: SERIAL values |
Date: | 2001-03-02 16:04:11 |
Message-ID: | Pine.BSI.4.21.0103021057140.14787-100000@glass.toledolink.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
This is an incorrect statement (as pointed out in the FAQ)
4.16.3) Don't currval() and nextval() lead to a race condition with other
users?
No. This is handled by the backends.
More info:
http://www.postgresql.org/users-lounge/docs/7.0/user/sql-createsequence.htm
When calling currval, you recieve the last value used by *your backend*
(regardless of what others have done).
Michael Fork - CCNA - MCP - A+
Network Support - Toledo Internet Access - Toledo Ohio
On Fri, 2 Mar 2001, Gregory Wood wrote:
> SELECT currval('Table_SerialField_SEQ');
>
> Note: This selects the last value of the sequence defined by your SERIAL
> sequence, not necessarily the value in your INSERT. For example:
>
> 1. User A INSERTs.
> 2. User B INSERTs.
> 3. User A performs SELECT currval, which returns the value for User B's
> INSERT.
>
> If this could be a potential problem, I recommend peforming a:
>
> SELECT nextval('Table_SerialField_SEQ');
>
> *before* you perform the INSERT, and explicitly using that value.
>
> Greg
>
> ----- Original Message -----
> From: "Kostis Mentzelos" <mentzelos(at)ematic(dot)com>
> To: <pgsql-general(at)postgresql(dot)org>
> Sent: Thursday, March 01, 2001 5:53 PM
> Subject: SERIAL values
>
>
> > Hi all,
> >
> > how can I get the current values from SERIAL types after an INSERT using
> >
> > libpq?
> >
> >
> > Thanks,
> > kostis.
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
> >
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>
From | Date | Subject | |
---|---|---|---|
Next Message | Rod Taylor | 2001-03-02 16:05:42 | Re: Re: Convert to upper |
Previous Message | Rod Taylor | 2001-03-02 15:55:32 | Re: Re: Thought on OIDs |