Regarding SQL in Perl, in general it is wise to always have a method of logging the SQL statement you build, especially when rolling SQL on the fly. Plus a method for dumping the values that are to be bound to a prepared statement.

Secondly, in your particular instance, you should be able to scatter prints through the code to see which one of the three statements is causing the trouble. You must narrow it down to one.

Finally, DBI's trace method will let you see exactly what is handed to the underlying DBD driver, with progressively excruciating detail according to how high you crank it up.

Taking a wild guess here now, I'd say that you have a trailing comma after a field or value. e.g. something like insert into t (c1, c2, c3,) values (1,2,3,)

Perl doesn't care about trailing commas in lists; in SQL it is an error.

- another intruder with the mooring in the heart of the Perl


In reply to Re: Debugging DBD/SQL syntax error by grinder
in thread Debugging DBD/SQL syntax error by dstefani

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.