On Thu, 2004-01-01 at 15:10, Stephane Pinel wrote: > Happy new year to all pgsql fans ! > > Sorry for this trivial question but I couldn't find an answer in the > archives : > > I use SERIAL type in tables for id columns in order to auto increment > them. Is there a way to get > the last inserted id in the table like we do with MySQL using the > GetLastInsertID ? > > My need is to get back the new id just after inserting. Is nextval can > respond to this need if I call it > just before inserting ?
You can use currval() after the insert (specifying DEFAULT for the SERIAL field), or nextval() to get an id to use in the insert. -- Oliver Elphick [EMAIL PROTECTED] Isle of Wight, UK http://www.lfix.co.uk/oliver GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C ======================================== "The LORD shall preserve thy going out and thy coming in from this time forth, and even for evermore." Psalms 121:8 ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster