 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| l |
The eval { … } catches
all exceptions
|
|
|
|
– |
not just from
DBI calls. Also catches fatal runtime errors from Perl.
|
|
| l |
Put commit() inside
the eval
|
|
|
|
– |
ensures commit
failure is caught cleanly.
|
|
|
|
– |
remember that commit()
itself may fail for many reasons.
|
|
|
| l |
Don't forget
that rollback() may also fail
|
|
|
|
– |
due to database
crash or network failure etc.
|
|
|
| l |
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.
|
|