On Thursday 04 October 2001 13:37, Paul DuBois wrote:
> At 4:08 PM -0400 10/4/01, Jason Frisvold wrote:
> >Is there a way to have DBI return the value of the auto-incremented field
> >upon insert? Or do I have to insert and then do a select afterwards?
>
> $dbh->do ("your insert statement");
> $auto_inc = $dbh->{mysql_insertid};
Be aware that at least older versions of Perl's DBI (maybe just the MySQL
driver?) have a bug wherein they do not return 64-bit values if your
auto-increment field is a BIGINT type. We spent a few days scratching our
heads on that one.
We got around this by explicitly doing a
SELECT LAST_INSERT_ID()
after each operation where we needed to know the ID. Ugly, but it worked
every time. It was ... fun ... tracking down all the places we'd used DBI
directly :-(
Best,
Kyle
Bot fodder: mysql, query, database
--
Quicknet has just released the following new products:
Internet SwitchBoard v5.5 and MicroTelco Gateway 2.0. We
have also added a new low cost carrier, Blue Star Telecom
to our award winning MicroTelco services. For more
information visit: www.quicknet.net or www.microtelco.com
---------------------------------------------------------
Those who desire to give up freedom in order to gain security
will not have, nor do they deserve, either one.
-Thomas Jefferson
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php