We must be looking at different documentations. When I look at the documentation of v1.631 of DBI for ->do, I see examples.

The examples do not match your code though, and I really wonder how your code compiles if it is supposed to be normal DBI code.

Maybe you want to learn about how DBI uses placeholders first?

I'm also unfamiliar with the SQL statement you seem to be using. I have never seen INSERT INTO ... SET foo=bar.

Also, you might want to read up on how DBI maps undef and NULL. A string NULL seems highly unlikely as a value for the column id.

Personally, I usually end up using the sequence of ->prepare, ->execute, ->finish:

my $dbh= DBI->connect('dbi:...', $user, $pass, { RaiseError => 1, Prin +tError => 0 }); # RaiseError is important so I can leave out all error handling my $sth= $dbh->prepare(<<'SQL'); INSERT INTO person SET id=?, first_name=?, last_name=?; SQL $sth->execute( undef, $first, $last ); $sth->finish;

In reply to Re: Replacing DBI->do() by Corion
in thread Replacing DBI->do() by jms53

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.