Re: SERIAL values - Mailing list pgsql-general

From Gregory Wood
Subject Re: SERIAL values
Date
Msg-id 007d01c0a32d$20de4fb0$7889ffcc@comstock.com
Whole thread Raw
In response to SERIAL values  (Kostis Mentzelos <mentzelos@ematic.com>)
Responses Re: Re: SERIAL values
List pgsql-general
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@ematic.com>
To: <pgsql-general@postgresql.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@postgresql.org
>


pgsql-general by date:

Previous
From: "Mitch Vincent"
Date:
Subject: Re: Want to learn the Postgresql database system
Next
From: "Martin A. Marques"
Date:
Subject: Re: platforms