Problems with transactions and sequences
От | Sune Nielsen |
---|---|
Тема | Problems with transactions and sequences |
Дата | |
Msg-id | j0trkvkn9i9n33ju2g909r3chs1rm2t5s9@4ax.com обсуждение исходный текст |
Ответы |
Re: Problems with transactions and sequences
Re: Problems with transactions and sequences |
Список | pgsql-general |
Hello All! Im suffering an appearantly common problem with psql, although I haven't been able to locate the proper solution. Using phpPgAdmin I've created a relation (note: this relation is grossly simplified but the problem remains the same) : CREATE TABLE Users ( bid SERIAL, name CHAR(8) NOT NULL, PRIMARY KEY (bid) ); Now, the problem is that I wish to extract the sequence number from a newly inserted user, like this: 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; This, however, doesn't work although I thought it should. It doesn't return anything at all?!?! Could somebody explain me what I'm doing wrong, or tell my how to do it instead? Any help would be greatly appreciated! -- Sune Nielsen sunegn@image.dk Student at Dept. of Computer Science Copenhagen University http://www.diku.dk
В списке pgsql-general по дате отправления: