On Mon, Mar 10, 2003 at 08:37:45AM -0800, Michael Peppler wrote: > > > > > > > > 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.
So the @@variables can't even be read by another stored procedure? If so, that seems remarkably unhelpful. Previously you said: > 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. So, any ideas? Taking a different tack... *if* @@identity is a sequence and AutoCommit is off then then "select max($column) from $table" would get it. No? Tim. > > > > 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