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

In reply to Re: Perl csv insert with special character by Tux
in thread Perl csv insert with special character by homer4all

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.