eval { $_->execute foreach @sth; }; if ($@) { $dbh->rollback; } else { $dbh->commit; }