MySQL Forums
Forum List  »  Perl

retrieve auto-increment value
Posted by: paul alcock
Date: May 25, 2009 08:54PM

In a perl cgi I successfully add a record to a table that has an auto-increment primary key (myEventID)

I can build an SQL statement that will add a record and return the value of myEventID and run it in myPHPAdmin

However I cannot figure out what the perl code equivalent is.

I'm trying this...(after connecting to the db) It does create the record, but does not return the autoincrement value.

$sqlcommand = $dbh->prepare($SQLInsert);
my $sqlAutoIncrement = $sqlcommand->{'mysql_insertid'};
print "\n\$sqlAutoIncrement $sqlAutoIncrement\n";
$dbh->disconnect ( );

TIA for any help on this.


Options: ReplyQuote

Written By
retrieve auto-increment value
May 25, 2009 08:54PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.