you can retrieve it using the currentVal function on the sequence used to generate that id.
"sebmil" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello, > > I have a table with two columns, created with : CREATE TABLE test ( id > serial primary key, name text ) ; > > To populate the table i use : > INSERT INTO test(name) values('test1'); so the "id" is automatically set > by PostgreSQL. > > Now the problem, i would like to retrieve the value of "id" that > PostgreSQL assigns to this tuple, but i can't make a SELECT on the name i > just inserted because it's not UNIQUE, so SELECT may return multiple > results. > > Is there a way to retrieve the value of "id" from the insertion ? > > I was thinking of something with Oids, like getting the Oid of the INSERT > statement then use it to SELECT the tuple, but i didn't find what to do > with an Oid in PostgreSQL documentation. > > Also, it would be better if it was possible in only one operation (not > INSERT then SELECT). > > Thanks in advance. ---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend