Re: Problems with transactions and sequences

From: "Shridhar Daithankar" <shridhar_daithankar(at)persistent(dot)co(dot)in>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Problems with transactions and sequences
Date: 2003-08-28 14:54:43
Message-ID: 3F4E650B.3698.795CE8@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2003-08-28 15:10:24 Re: Functions have 32 args limt ???
Previous Message Thomas Beutin 2003-08-28 14:52:16 left outer join terrible slow compared to inner join