in reply to SQLite: INSERT into a unique column and retrieve rowid
From my code... You can call last_insert_id with no args (all undef) which probably would be fine in your app. Or in my code I asked specifically about the ScoreCard Table.
On another point, from your code:my $scoreCardrow = $dbh->last_insert_id(undef,undef,"ScoreCard",undef) +; # last_insert_id($catalog, $schema, $table, $field);
You do not need this line. SQLite cannot generate a table without a unique row id. If that line is missing, SQLite generates:CREATE TABLE Songs (id INTEGER PRIMARY KEY,
Update: Complications can occur with multiple writers, but I don't think that is an issue with your code.
my $rowid = $sths{$table}{SELECT}->execute($value) || die;
I think we covered how to get last rowid. You do not need "|| die" because you have RaiseError =1 which is what I recommend.
Another fine point, 0E0 this is the DB's way of saying logical "true", but numeric "zero".
$dbh->do("CREATE INDEX ix_song ON Songs (song)");
I would leave the index off completely to start with and see how the performance is. You may be surprised at how well SQLite does on its own. The index adds considerably to the time for each insert. There are weird things that can happen in complex tables if you "overindex" them. This confuses the execution strategy engine and you can wind up with slower code! Anyway be careful.
|
|---|