The ideal first step would be to use DBI placeholders instead of creating a string-SQL statement. The second step would be to use Text::CSV_XS for parsing your delimited input file.
my $sth_insert = $dbi->prepare(<<'SQL'); INSERT INTO biochemical VALUES (?,?,?,?,?,?,?,?,?,?,...,?) SQL for my $row (@rows) { $sth_insert->execute( @$row ); };
By using DBI placeholders, you don't need to care about special characters like double quotes in strings.
Then, when inserting, switch off the RaiseError flag:
local $sth_insert->{RaiseError} = 0; for my $row (@rows) { $sth_insert->execute( @$row ); };
That way, the script does not die anymore on insert errors.
In reply to Re: Skip problematic lines while populating database
by Corion
in thread Skip problematic lines while populating database
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |