in reply to DBI and transactions
no. Since, in your code, you are committing each row, a rollback will only affect the current row being executed. if you want the entire block to rollback, you will have to commit only at the end of the transaction.
so you should use the code you listed in part 2.
Also, while using DBI, make sure you turn off autocommit, i.e.:eval { #table A foreach line (...) { prepare, execute } #table B prepare, execute } if ( $@ ) { rollback } else { commit; }
otherwise you may be committing each row automatically; it depends on the DBD default setting.my $dbh = DBI->connect('DBI:MSSQL:database', {AutoCommit => 0}, ) or die "Couldn't connect to database: " . DBI->errstr;
--
.dave.
|
|---|