in reply to Auto-Increment and DBD Agnosticism
As you have discovered getting this value from the various database server engines requires some very different approaches. The most generic approach is to simply do a SELECT max(idvalue) FROM table right after the insert. If you are running with AutoCommit OFF, and if the server supports transactions then this should return the correct value, as long as you COMMIT after the SELECT max(). Otherwise this is open to a race condition in the case of multiple inserts to that same table.
And FYI - for Sybase and MS-SQL the last inserted id (IDENTITY value) can be retrieved with a SELECT @@identity.
Michael
|
|---|