in reply to Escape characters in DBD CSV
$dbh->do("UPDATE new_entrant SET forename='$wrk_forename',surname='$wrk_surname' FROM new_entrant WHERE emp_no='$wrk_emp_no'") or die $DBI::errstr;
NEVER put literal values <update>value literals</update> into SQL statements, use placeholders ($dbh->do('UPDATE sometable SET foo=?,bar=?,baz=? WHERE quux=?',undef,$foo,$bar,$baz,$quux);). See DBI, Re: Counting rows Sqlite, Re^2: Massive Memory Leak, Re^5: Variable interpolation in a file to be read in.
Also note that there is no FROM in an UPDATE statement.
And finally, enable autodie in DBI->connect(), that removes the need for or die $DBI::errstr for all DBI methods.
Alexander
Updated wording, thanks to soonix.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Escape characters in DBD CSV
by chacham (Prior) on May 11, 2015 at 15:09 UTC |