in reply to Perl csv insert with special character

The code still is way too terse to give useful comments. I understand that you had to make a manual copy (which had too many errors to expect useful comments), but otoh you could have taken a bit more time to come up with valid code that still shows the erroneous behavior.

From your code, it looks like you do not use the "standard" DBI interface, so suggesting debug actions in that area are likely to be inapplicable.

You have posted no single error message, so what do you expect us to reply on? WE HAVE NO CLUE IN WHAT GOES WRONG!

In your three line data example I see no reason for allow_loose_quotes

Simplify your code to a more perlish manner:

open my $fh, "<", $fileToInsert or die "$filetoInsert: $!" my $csv = Text::CSV->new ({ binary => 1, auto_diag => 1, allow_white_space => 1, }); # I have to assume prepare () is a *function* in a singleton # instead of the method provided by DBI my $sth = prepare ( "insert into TAB1 (sample_date, server, n1, n2, command) values (? +,?,?,?,?)"); while (my $row = $csv->getline ($fh)) { $sth->execute (@$row); }

Text::CSV's getline returns an arraref, so the next line - would you have used strict and warnings - would have caused a lot of noise, as you would need a dereference like $row->[0] instead of $row[0], and on that line there is no need to name all of them separately, as you are using all of them anyway, so use @$row.

All of my comments show that you really really need to post code that parses, as we cannot see where the original code goes awry.


Enjoy, Have FUN! H.Merijn