I don't know DBD::ODBC directly but one thought that occured to me was "Do you need to pass a statement handle to Sql instead of a scalar containing some sql to execute?"
Alternately this could be done with 2 statement handles along these lines:
#the stuff at the top up to $sth->execute; my $insh=$dbh->prepare("INSERT INTO TestClearTransferData(AccountNo, T +ransferFlag, TransferType, RejectType, AdpNumber, Shares, ProcessingD +ate) VALUES ( ?, ?, ?, ?, ?, ?, ? )"); eval { while((@data) = $sth->fetchrow_array) { $insh->execute(@data); } }; if($@) { print STDERR "The insert died: $@"; } ...
Since RaiseError is set the eval will die if theres a problem. Also the placeholders will speed up the inserts. And if you could set AutoCommit to 0 on the database getting the inserts you could do all of them in a transaction so that all are successful or none are successful, thus not leaving a messy table half way through the inserts if there is a problem.
In reply to Re: Problem with Code
by dga
in thread Problem with Code
by SamueD2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |