On Fri, Jan 14, 2005 at 11:39:54AM +0100, Bo Lorentsen wrote: > Thanks, but this demands you to have the table and id_column name in > your hand, and I don't right now. You can create a function to get the sequence name attached to a table. Of course, you should take into account the fact that there could be more than one (two serial fields in a table are rare but not impossible), but if your tables have only one sequence you should be OK. Something with select relname, relkind from pg_depend join pg_class on (oid = objid) where pg_depend.refobjid = 'foo'::regclass and relkind = 'S'; (only lightly tested). Then you can use that to construct your argument to the nextval() function. > Also ... the "currval" function are specifik to postgresql, and there > are nothing like it in mysql that can make any garanti for getting row > for newly inserted data. You can access autoincrement values in mysql, > but no garanties are given about its value (someone else have inserted a > new in the same table). This doesn't happen with sequences on Postgres. The value you get is guaranteed to be the one the sequence generated for you. -- Alvaro Herrera (<alvherre[@]dcc.uchile.cl>) "Those who use electric razors are infidels destined to burn in hell while we drink from rivers of beer, download free vids and mingle with naked well shaved babes." (http://slashdot.org/comments.pl?sid=44793&cid=4647152) ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html