9 messages in com.mysql.lists.mysqlRE: last_inserted_id
FromSent OnAttachments
Monika Plawna12 Apr 2000 11:07 
Matt Levine12 Apr 2000 11:22 
Monika Plawna12 Apr 2000 11:47 
Robert Goff12 Apr 2000 12:07 
Sam Mefford12 Apr 2000 12:19 
Monika Plawna12 Apr 2000 12:35 
Monika Plawna12 Apr 2000 13:22 
Thimble Smith13 Apr 2000 02:20 
Monika Plawna13 Apr 2000 09:56 
Subject:RE: last_inserted_id
From:Robert Goff (rob@goff.com)
Date:04/12/2000 12:07:19 PM
List:com.mysql.lists.mysql

- my $req_id = $dbh ->do ('select last_insert_id()'); - - right after I perform an insert. I check the tables manually and the - entries get inserted properly, but the above statement always returns 1.

You're getting the status of the operation, not the value of the statement. 'do' doesn't return a value, just a status. You'll have to go through the prepare, execute, fetch sequence if you want to use the select statement.

Or you could use the db handle attribute: The DBD::mysql driver supports the following attributes of database handles (read only):

$infoString = $dbh->{'info'}; $threadId = $dbh->{'thread_id'}; $insertId = $dbh->{'mysql_insertid'}

These correspond to mysql_info(), mysql_thread_id() and mysql_insertid(), respectively.