[prev in list] [next in list] [prev in thread] [next in thread]
List: msql-mysql-modules
Subject: Re: Trying to get the last inserted ID
From: Michael R Boudreau <mboudreau () press ! uchicago ! edu>
Date: 2009-03-31 16:26:45
Message-ID: C5F7AE75.17EB4%mboudrea () ad ! uchicago ! edu
[Download RAW message or body]
According to "Programming the Perl DBI" (O'Reilly 2000), the syntax varies depending \
on your version of DBD::mysql:
If you used a prepare/execute:
$sth->{mysql_insertid} (1.21_xx)
$sth->{insertid} (1.20_xx)
If you used $dbh->do:
$dbh->{mysql_insertid} (1.21_xx)
$dbh->do("SELECT LAST_INSERT_ID()") (1.20_xx)
On 3/31/09 10:49 AM, "Vance E. Neff" <veneff@intouchmi.com> wrote:
Hello,
I have inserted a new row into a table that has an auto incrementing key.
For some reason, I don't seem to be able to retrieve it after it is created.
I tried these two statements:
$LoginID = $dbh->last_insert_id( "", "", "Logins", "LoginID" );
and
$LoginID = $dbh->{'mysql_insertid'};
in both cases, $LoginID comes back undefined.
I tried before the COMMIT and after with the same results. Note that
auto commit is currently turned on, so my commits should have anything
to do with anything.
What am I doing wrong?
Note that I have verified that the key is being created with the
expected values.
Vance
--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=mboudreau@press.uchicago.edu
--
Michael R. Boudreau
Senior Publishing Technology Analyst
The University of Chicago Press
1427 E. 60th Street
Chicago, IL 60637
(773) 753-3298 fax: (773) 753-3383
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic