From: Aleksi Date: 2005-06-23T14:55:37+09:00 Subject: Re: PostgreSQL Inserted OID nexus wrote: > Does anyone know how to get the inserted OID following an insert > statement in PostgreSQL (using DBI and/or Postgres Lib)? I'm not having > any luck finding the answer. I don't know what is the "right" answer, but I know how one piece of software handles the issue. Og does this in two separate statements: 1) res = store.conn.exec "SELECT nextval('#{klass::OGSEQ}')" 2) store.conn.exec("INSERT INTO #{klass::OGTABLE} (#{props.collect {|p| p.symbol.to_s}.join(',')}) VALUES (#{values})").clear Which basically means there's a sequence for each of the managed classes together with the table objects are really kept for persistence. Maybe this solution is viable for you too. Maybe all this should be in one transaction. Maybe this should be a stored procedure (as George has put in a code as a todo task). Maybe you should do something completely different. - Aleksi