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 su****@image.dk
Student at
Dept. of Computer Science
Copenhagen University
http://www.diku.dk