get value of auto-incremented primary key

From: Oliver Schaedlich (just_oliver_at_gmx.net)
Date: 01/19/04


Date: Mon, 19 Jan 2004 02:13:23 +0100
To: dbi-users@perl.org

Hello everyone,

I'd like to feed a simple MySQL database with entries, where each
entry gets an auto-incremented, integer primary key `testINDEX`.
I would do something like this:

$rc = $dbh -> do ( "INSERT INTO `$tablename`
                   ($fields_string) VALUES ($values_string)" );

Of course, now I don't know which key is actually assigned.
Is it possible to get the value MySQL assigns to testINDEX
during this insertion? Something along the lines of:

do "insertion"
do "get key assigned during last insertion"

My knowledge of both sql and dbi is very limited - please bear with
me. Thank you in advance.
  
Best regards,
Oliver.



Relevant Pages