Does this mean that I literally type in 'default_blah' and it will insert "NA" or do I need to be putting 'NA' where 'default_blah' is?

I was hoping for a solution so that if I didn't know what the default value was I could still write a query that would insert the default value if the user hadn't provided one.

- Sorry didn't see the solution offered by graff below before I posted this. Is there a reason why you have used a combination of " and '?
my $sth = $dbh->prepare('INSERT INTO foo SET ' . "bar = isnull(?, 'default_bar'), ' . "blah = isnull(?, 'default_blah')) "
Must admit the mixing of " and ' characters is confusing and when I plug it into my code as is I get some errors.
Bareword found where operator expected at line 442, near ". "blah " (Might be a runaway multi-line "" string starting on line 441) (#1) (S syntax) The Perl lexer knows whether to expect a term or an ope +rator. If it sees what it knows to be a term when it was expecting to see + an operator, it gives you this warning. Usually it indicates that an operator or delimiter was omitted, such as a semicolon. (Missing operator before blah?) Unquoted string "blah" may clash with future reserved word at line 442 + (#2)
Line 442 is:
. "blah = isnull(?, 'default_blah')) "

In reply to Re^2: Using MySQL table's default values upon insert by Zettai
in thread Using MySQL table's default values upon insert by Zettai

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.