On Tue, 2003-03-11 at 12:50, Tim Bunce wrote: > [ignore the previous 'empty' reply, finger trouble] > > On Tue, Mar 11, 2003 at 09:20:48AM -0800, Michael Peppler wrote: > > On Mon, 2003-03-10 at 15:50, Tim Bunce wrote: > > > 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? > > > > Yes. > > > > But then you won't be able to reuse that handle to make a second insert > > (as you know, of course). > > I'm probably just not familar enough with how DBD::Sybase works, > but that seems odd. I thought the only reason for using separate > connections was for when one $sth still had results to be fetched.
It looks like it pays to question things. The following works, although I was sure it wouldn't: my ($sth, $sth2); $sth = $dbh->prepare("insert dbi_insert(c, i) values(?,?)"); for(my $i = 0; $i < 2; $i++) { $sth->execute("foo", 1); $sth2 = $dbh->prepare("select max(id) from dbi_insert"); $sth2->execute; while(my $d = $sth2->fetch) { print "identity = @$d\n"; } } Both $sth and $sth2 are on the same connection, and $sth *can* be reused after $sth2 is done. Which means that fetching the values will be a little easier (although there are locking issues, of course!) Thanks for prodding me on this Tim! 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