--- Magnus Hagander <magnus@xxxxxxxxxxxx> wrote: > If you're on 8.2 the easiest way is to use INSERT RETURNING. For example: > INSERT INTO t (somefield) VALUES ('somevalue') RETURNING pkey > > with pkey being the SERIAL field. I don't want to derail the thread too much, but would it be nice if the returning could be used in a insert sub-query? INSERT INTO Childtable ( parentfkey, childname ) VALUES ( ( INSERT INTO Parenttable ( parentname ) VALUES ( 'FRED' ) RETURNING pkey ), 'Jed'); This with one statement, you could insert into two or more tables. Regards, Richard Broersma Jr.