Re: Problems with transactions and sequences
От | Sune Nielsen |
---|---|
Тема | Re: Problems with transactions and sequences |
Дата | |
Msg-id | ik7skv41daok18fbo51ifh9de34gu8vbgd@4ax.com обсуждение исходный текст |
Ответ на | Problems with transactions and sequences (Sune Nielsen <sunegn@image.dk>) |
Список | 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 по дате отправления: