Actually, you'd want the try/catch outside the <cftransaction..> because the
catch clause would prevent the second transaction tag from executing.  This
isn't a big deal if you explicitly specify the rollback command, but you
don't have to do that if you put the try/catch outside the transaction.

In the following example the the first two queries would commit even though
the third errors out:
<cftransaction>
<cftry>
        <cfquery datasource="blove_syb5" name="">
                good query
        </cfquery>
        <cfquery datasource="blove_syb5" name="">
                good query
        </cfquery>
        <cfquery datasource="blove_syb5" name="">
                bad query
        </cfquery>
<cfcatch>
        oops
</cfcatch>
</cftry>
</cftransaction>

In this example it works as you expect: the first two queries are rolled
back before the cfcatch tag is executed.  In the above example you would
have to specify a rollback tag, but in this one you don't.
<cftry>
<cftransaction>
        <cfquery datasource="blove_syb5" name="">
                good query
        </cfquery>
        <cfquery datasource="blove_syb5" name="">
                good query
        </cfquery>
        <cfquery datasource="blove_syb5" name="">
                bad query
        </cfquery>
</cftransaction>
<cfcatch>
        oops
</cfcatch>
</cftry>

+-----------------------------------------------+
Bryan Love
  Database Analyst
  Macromedia Certified Professional
  Internet Application Developer
TeleCommunication Systems
[EMAIL PROTECTED]
+-----------------------------------------------+

"...'If there must be trouble, let it be in my day, that my child may have
peace'..."
        - Thomas Paine, The American Crisis

"Let's Roll"
        - Todd Beamer, Flight 93



-----Original Message-----
From: Barney Boisvert [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 28, 2003 1:49 PM
To: CF-Talk
Subject: RE: <cftransaction> <cftry> order


The first one, so you can rollback the transaction in the CFCATCH block:

<cftransaction action="begin">
   <cftry>

   <cfquery>
   <cfquery>
   <cfquery>

   <!--- this is optional --->
   <cftransaction action="commit" />

   <cfcatch>
      <!--- something happened, roll it back --->
      <cftransaction action="rollback" />
   </cfcatch>
   </cftry>
</cftransaction>

---
Barney Boisvert, Senior Development Engineer
AudienceCentral (formerly PIER System, Inc.)
[EMAIL PROTECTED]
voice : 360.756.8080 x12
fax   : 360.647.5351

www.audiencecentral.com

> -----Original Message-----
> From: Andy Ousterhout [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, May 28, 2003 12:38 PM
> To: CF-Talk
> Subject: <cftransaction> <cftry> order
>
>
> Brain cramp....Which is best/correct:
>
> <cftransaction>
>     <cftry>
>
>     <cfcatch>
>
>     </cftry>
> </cftransaction>
>
> OR
>
> <cftry>
>     <cftransaction>
>
>     </cftransaction>
>
>     <cfcatch>
> </cftry>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
http://www.cfhosting.com

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to