On Mon, Mar 10, 2003 at 02:50:08PM -0800, Michael Peppler wrote: > On Mon, 2003-03-10 at 12:36, Tim Bunce wrote: > > > > Taking a different tack... *if* @@identity is a sequence and AutoCommit > > is off then then "select max($column) from $table" would get it. No? > > Yes, that would work. > > However, the following won't: > > $sth = $dbh->prepare('insert foo(...) values(?,...)'); > $sth->execute('bar', ...); > $id_sth = $dbh->prepare('select max(id) from foo'); > > because now $id_sth resides on a different physical connection. You'd > have to finish() the original $sth,
Can't DBD::Sybase tell it's an insert and automatically finish() after the execute? Tim. > and then do the second prepare() to > get the max() value, which is of course rather annoying if you're doing > a bunch of inserts (though it's maybe unlikely that you really need the > last_id value if you're doing a batch of inserts).