Re: Problems with transactions and sequences - Mailing list pgsql-general

From Shridhar Daithankar
Subject Re: Problems with transactions and sequences
Date
Msg-id 3F4E650B.3698.795CE8@localhost
Whole thread Raw
In response to Problems with transactions and sequences  (Sune Nielsen <sunegn@image.dk>)
Responses Re: Problems with transactions and sequences
List pgsql-general
On 28 Aug 2003 at 14:35, Sune Nielsen wrote:
> INSERT INTO Users (name) VALUES ('JohnDoe');
> SELECT CURRVAL('users_bid_seq');
>
> This works perfectly(!), but my project involves multiple simultanous
> users so I have to use transactions like this:
>
> BEGIN;
> INSERT INTO Users (name) VALUES ('JohnDoe');
> SELECT CURRVAL('users_bid_seq');
> COMMIT;

You need to extract the current val first and explicitly use it in insert
statement. That way you won't have to produce work-arounds later..

Bye
 Shridhar

--
Vulcans do not approve of violence.        -- Spock, "Journey to Babel", stardate
3842.4


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Problems with transactions and sequences
Next
From: Robby Russell
Date:
Subject: Re: Books for PostgreSQL?