in reply to DBI and primary keys

I think DBI cannot help you here.
This depends solely on the RDBMS.

For Sybase ASE and mssql the following sql-statement should give you the correct value:

select @@identity