or, with short-hand for simple binding and a here-doc:my $sql = 'INSERT INTO test_table VALUES (?,?,?,?,?,?)'; my $sth = $dbh->prepare($sql); $sth->bind_param(1, 'test_env'); $sth->bind_param(2, $partner); $sth->bind_param(3, $id); $sth->bind_param(4, $filename); $sth->bind_param(5, "$date $time"); $sth->bind_param(6, $line_count); $sth->execute();
If you want to bypass this step, you would probably just execute the SQL with a $dbh->do.my $sql = <<EOSQL; INSERT INTO test_table VALUES (?,?,?,?,?,?) EOSQL my $sth = $dbh->prepare($sql); $sth->execute('test_env', $partner, $id, $filename, "$date $time", $line_count, );
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
In reply to Re: DB Exception Handling
by kennethk
in thread DB Exception Handling
by sowais
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |