in reply to Getting ID of last row inserted into database

The search terms you're looking for are last insert id. And unsurprisingly, DBI has $dbh->last_insert_id ...

Replies are listed 'Best First'.
Re^2: Getting ID of last row inserted into database
by VSarkiss (Monsignor) on Jan 25, 2006 at 20:24 UTC
      yes...had some problems with that, but with this parameter combination:
      $self->db->dbh->last_insert_id(undef, undef, 'tablename', 'id_name');
      SQLite, MySQL 4.0 and PostgreSQL 8.1 all pass my tests. I think SERIAL UNIQUE NOT NULL was also necessary for Pg, but not sure.

      Aye. Reading the DBI docs that Corion pointed me to were a great help. I ended up with the following as my call to last_insert_id:

      my $LastID = $dbh->last_insert_id(undef, 'public', 'CUSTOMER_INFORMATION', 'ID');