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

From Sune Nielsen
Subject Re: Problems with transactions and sequences
Date
Msg-id ik7skv41daok18fbo51ifh9de34gu8vbgd@4ax.com
Whole thread Raw
In response to Problems with transactions and sequences  (Sune Nielsen <sunegn@image.dk>)
List pgsql-general
On Thu, 28 Aug 2003 20:24:43 +0530,
shridhar_daithankar@persistent.co.in ("Shridhar Daithankar") wrote:

>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..
As I could read from the reply from Tom Lane, it seemed that I only
needed to to remove the BEGIN and COMMIT in order to make it work.
What problems do you foresee if don't perform the queries in opposite
order? I'm kind of new to this stuff :-)

Thanks for your fast reply!


--
Sune Nielsen sunegn@image.dk
Student at
Dept. of Computer Science
Copenhagen University
http://www.diku.dk

pgsql-general by date:

Previous
From: Sune Nielsen
Date:
Subject: Re: Problems with transactions and sequences
Next
From: "Marc G. Fournier"
Date:
Subject: Re: Let's see if this helps ... more anti-virus/anti-spam