The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

<!--  Presentation generated by Internet Assistant for Microsoft PowerPoint 97 -->

<HTML>
<HEAD>

<meta name="GENERATOR" content="Microsoft Internet Assistant for Microsoft PowerPoint 97">
 <TITLE>Transactions - How the DBI helps</TITLE> 
</HEAD>

<BODY     >

<CENTER>
<TABLE WIDTH=100%> 
     <TR> <TD WIDTH=100% ALIGN=CENTER>
         <A HREF="sld001.htm">First</A>&nbsp;&nbsp;
         <A HREF="sld039.htm">Previous</A>&nbsp;&nbsp;
         <A HREF="sld041.htm">Next</A>&nbsp;&nbsp;
         <A HREF="sld080.htm">Last</A>&nbsp;&nbsp;
&nbsp;&nbsp;         <A HREF="index.htm">Index</A>&nbsp;&nbsp;
         <A HREF="http://dbi.perl.org">Home</A>&nbsp;&nbsp;
         <A HREF="tsld040.htm">Text</A>&nbsp;&nbsp;
     </TD> </TR>
     <TR> <TD WIDTH=100% ALIGN=CENTER>
         <IMG SRC="img040.gif" usemap="#Objmap" WIDTH=800 HEIGHT=600 BORDER=0>
     </TD> </TR>
</TABLE>
<P>Slide 40 of 80</P>
</CENTER>
<!-- <UL>
<H2>Transactions - How the DBI helps</H2>
</UL></P>
<P><UL>
<LI><H2>Tools of the trade:
</H2>
<UL>
<LI>Set AutoCommit off, and RaiseError on
<LI>Wrap eval { … } around the code
<LI>Use $dbh-&#062commit; and $dbh-&#062rollback;
<UL>
<LI>
</UL></UL></UL><UL>
<LI><H2>Disable AutoCommit via $dbh-&#062{AutoCommit} = 0;
</H2>
<UL>
<LI>to enable transactions and thus rollback-on-error
</UL></UL><UL>
<LI><H2>Enable RaiseError via $dbh-&#062{RaiseError} = 1;
</H2>
<UL>
<LI>to automatically 'throw an exception' after an error
</UL></UL><UL>
<LI><H2>Add surrounding eval { … }
</H2>
<UL>
<LI>catches the exception, the error text is stored in $@
</UL></UL><UL>
<LI><H2>Test $@ and $dbh-&#062rollback() if set
</H2>
<UL>
<LI>note that a failed statement doesn’t automatically trigger a transaction rollback</UL></UL></P>
<P>  -->
</Body>
</HTML>