Transactions - Example code
$dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;
eval {
$dbh->method(…); # assorted DBI calls
foo(...); # application code
$dbh->commit; # commit the changes
};
if ($@) {
warn "Transaction aborted because $@";
$dbh->rollback;
...
}