On Mon, 2003-03-10 at 08:27, Tim Bunce wrote:
> On Mon, Mar 10, 2003 at 07:41:19AM -0800, Michael Peppler wrote:
> > On Sat, 2003-03-08 at 13:11, Tim Bunce wrote:
> > > 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?
> > 
> > > > 
> > > > 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.
> > > > 
> > 
> > > 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)?
> > 
> > Unfortuantely no. YOu have no control over the content of the temp.
> > stored proc beyond the actual insert statement.
> 
> Which 'you'? Doesn't DBD::Sybase created those temporary stored
> procedures itself?

No - the Sybase server does.

DBD::Sybase just uses the Sybase API (ct_dynamic() and friends). This
sends the query to be prepared to the server, which creates the temp
proc. This makes it fast because the procs are never recorded in any of
the system tables. If DBD::Sybase had to create the procs on the fly the
process would be rather slow, and there would be a lot of lock
contention between clients wanting to execute dynamic requests.

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