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.

Michael
-- 
Michael Peppler                              Data Migrations, Inc.
[EMAIL PROTECTED]                 http://www.mbay.net/~mpeppler
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or 
long term contract positions - http://www.mbay.net/~mpeppler/resume.html

Reply via email to