in reply to SQLite: INSERT into a unique column and retrieve rowid
->execute($value) does not return the rowid.
See last_insert_id of DBI on how to use ->last_insert_id. Also, you can use the RETURNING SQL clause:
my $sql = <<"SQL"; INSERT INTO $table ($column) VALUES (?) RETURNING id SQL my $sth = $dbh->prepare($sql); $sth->execute(...); my $rows = $sth->fetchall_arrayref( {} ); say "New id: " . $rows->[0]->{id};
|
|---|