Transactions - How the DBI helps
 
 
- Tools of the trade:
- 
- Set AutoCommit off
- Set RaiseError on
- Wrap eval { … } around the code
- Use $dbh->commit; and $dbh->rollback;
 
- Disable AutoCommit via $dbh->{AutoCommit}=0 or $dbh->begin_work;
- 
- to enable use of transactions
 
- Enable RaiseError via $dbh->{RaiseError} = 1;
- 
- to automatically 'throw an exception' when an error is detected
 
- Add surrounding eval { … } 
- 
- catches the exception, the error text is stored in $@
 
- Test $@ and then $dbh->rollback() if set
- 
- note that a failed statement doesn’t automatically trigger a transaction rollback