Transactions - Further comments
 
 
- The eval { … } catches all exceptions
- 
- not just from DBI calls. Also catches fatal runtime errors from Perl
 
- Put commit() inside the eval
- 
- ensures commit failure is caught cleanly
- remember that commit() itself may fail for many reasons
 
- Don't forget that rollback() may also fail
- 
- due to database crash or network failure etc.
- so you may want to call eval { $dbh->rollback() };
 
- Other points:
- 
- Always explicitly commit or rollback before disconnect()
- Destroying a connected $dbh should always rollback
- END blocks can catch exit-without-disconnect to rollback and disconnect cleanly