I've started a tiny Perl module called DBIx::GeneratedKey, which
allows you to fetch last inserted object id independently on DBDs.

  http://bulknews.net/lib/archives/DBIx-GeneratedKey-0.01/

You know this is a trivial port of JDBC ver.3's getGeneratedKeys method.
Any requests/suggestions/patches welcome.

The difficult bit is handling PostgreSQL, which has oid even if a
table has a SERIAL primary key. Currently, a sequence is fetched via
'SELECT CURRVAL' SQL, and oid is fetched via $sth->{pg_oid_status},
which might lead to confusions.

It seems that PostgreSQL JDBC driver doesn't support getGeneratedKeys
method.

http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc3/AbstractJdbc3Statement.java



-- 
Tatsuhiko Miyagawa <[EMAIL PROTECTED]>

Reply via email to