 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| l |
Tools of the
trade:
|
|
|
|
n |
Set AutoCommit off,
and RaiseError on
|
|
|
|
n |
Wrap eval { … } around
the code
|
|
|
|
n |
Use $dbh->commit;
and $dbh->rollback;
|
|
|
| l |
Disable
AutoCommit via $dbh->{AutoCommit}
= 0;
|
|
|
– |
to enable
transactions and thus rollback-on-error
|
|
|
| l |
Enable
RaiseError via $dbh->{RaiseError}
= 1;
|
|
|
|
– |
to automatically
'throw an exception' on error
|
|
|
| l |
The surrounding eval { … }
|
|
|
|
– |
catches the
exception and puts the error message into $@
|
|
|
| l |
Test $@ and rollback() if set,
else commit()
|
|