<HTML>
<HEAD>
<meta name="GENERATOR" content="Microsoft Internet Assistant for PowerPoint 97">
<TITLE>Transactions - Further comments</TITLE>
</HEAD>
<BODY >
<H1>Transactions - Further comments</H1>
<P><UL>
<LI><H2>The eval {
} catches all exceptions
</H2>
<UL>
<LI>not just from DBI calls. Also catches fatal runtime errors from Perl
</UL></UL><UL>
<LI><H2>Put commit() inside the eval
</H2>
<UL>
<LI>ensures commit failure is caught cleanly
<LI>remember that commit itself may fail for many reasons
</UL></UL><UL>
<LI><H2>Don't forget that rollback() may also fail
</H2>
<UL>
<LI>due to database crash or network failure etc.
<LI>so you'll probably want to use eval { $dbh->rollback };
</UL></UL><UL>
<LI><H2>Other points:
</H2>
<UL>
<LI>Always explicitly commit or rollback before disconnect
<LI>Destroying a connected $dbh should always rollback
<LI>END blocks can catch exit-without-disconnect to rollback and disconnect cleanly
<LI>You can use ($dbh && $dbh->{Active}) to check if still connected
</UL></UL><UL>
<H2>-</H2>
</UL></P>
<P></P>
<P>
<TABLE>
<TD HEIGHT=100 WIDTH=100> <A HREF="tsld054.htm">Previous slide</A> </TD>
<TD HEIGHT=100 WIDTH=100> <A HREF="tsld056.htm">Next slide</A> </TD>
<TD HEIGHT=100 WIDTH=150> <A HREF="tsld001.htm">Back to first slide</A> </TD>
<TD HEIGHT=100 WIDTH=150> <A HREF="sld055.htm">View graphic version</A> </TD>
</TABLE>
<BR>
</P>
</Body>
</HTML>