in reply to Re: Using MySQL table's default values upon insert
in thread Using MySQL table's default values upon insert
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 '?Must admit the mixing of " and ' characters is confusing and when I plug it into my code as is I get some errors.my $sth = $dbh->prepare('INSERT INTO foo SET ' . "bar = isnull(?, 'default_bar'), ' . "blah = isnull(?, 'default_blah')) "
Line 442 is: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)
. "blah = isnull(?, 'default_blah')) "
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Using MySQL table's default values upon insert
by roboticus (Chancellor) on Jan 30, 2010 at 23:23 UTC |