Re: Problems with transactions and sequences

From: Sune Nielsen <sunegn(at)image(dot)dk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Problems with transactions and sequences
Date: 2003-08-28 15:27:44
Message-ID: ik7skv41daok18fbo51ifh9de34gu8vbgd@4ax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 28 Aug 2003 20:24:43 +0530,
shridhar_daithankar(at)persistent(dot)co(dot)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(at)image(dot)dk
Student at
Dept. of Computer Science
Copenhagen University
http://www.diku.dk

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joe Conway 2003-08-28 15:35:02 Re: Functions have 32 args limt ???
Previous Message Tom Lane 2003-08-28 15:25:57 Re: Date Time Function / Age