in reply to Keeping Perl DBI Quiet

I had a fuss with DBI too, when I wanted to insert a lot of rows. If a row was already there, DBI would spit out errors (as it should), but it was not what I wanted. I didn't care if the row couldn't be inserted, I only wanted them in there once anyways. I used the following to solve it (note the OR IGNORE):
$dbh->prepare_cached("INSERT OR IGNORE INTO table VALUES (?,?,?,?)");
(Note: This was used with DBD::SQLite)

HTH

--
B10m

Replies are listed 'Best First'.
Re^2: Keeping Perl DBI Quiet
by Coruscate (Sexton) on Nov 26, 2003 at 06:01 UTC

    And if you're using DBD::mysql, you take out the 'OR' in that query:

    my $sth = $dbh->prepare('INSERT IGNORE INTO table VALUES(?,?,?); $sth->execute(@foo);