On Fri, Mar 07, 2003 at 04:28:33PM -0800, Michael Peppler wrote: > On Fri, 2003-03-07 at 14:15, Tim Bunce wrote: > > I'd appreciate a summary of which drivers support some form of > > ``last insert id'' and details of the interface they provide. > > > > Specifically... > > via an attribute or method? > > at the sth or dbh level, or both? > > any other details that might be relevant... > > > > Also, for databases that do _not_ support a ``last insert id'' > > concept in the client API, are there any SQL mechanisms for finding > > the last insert id? > > For Sybase you issue a "select @@identity" right after the insert. I > believe that this will also work with MS-SQL. > > The @@identity value is a global Transact-SQL variable that is localized > to the connection. > > Note that you *can't* get at the @@identity value if you insert data > using placeholders. This is because Sybase also localizes the > @@variables within each stored procedure, and when using placeholders > Sybase creates a temporary stored procedure for you on the fly. > > Off-hand I'm not sure how a last_insert_id() method would work for > DBD::Sybase, but there may be a way to build something that is at least > semi-reliable.
Could the generated temporary stored procedure copy @@identity to a non-localized session variable (where it could then be read by DBD::Sybase if the application wants the last_insert_id)? Tim.