heres what i use:

 

<cfset errmsg="">
 <cfset docommit = true>
 <cftransaction action="">
  <cftry>

    <!--- do your queries/cfc calls here --->   


   <cfcatch>
    <cfset docommit = false>
    <cfset errmsg = "#cfcatch.message#,#cfcatch.detail#">
   </cfcatch> 
  </cftry>
  
  <cfif docommit>
   <cftransaction action=""/>
  <cfelse>
   <cftransaction action=""/>
  </cfif>
 </cftransaction>
 
 <cfif len(errmsg)>
  <cfdump var="#cfcatch.tagcontext#">
 </cfif>

 

 

 -----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Ian Skinner
Sent: 23 November 2004 16:19
To: [EMAIL PROTECTED]
Subject: [CFCDev] Will this <cftransaction> work?

If I have a block of code that is going to call several queries, and I have placed the queries into functions of a CFC, can I wrap these calls into a single transaction?

 

Basically I will have something like this.

 

<!--- Update several related tables --->

<cftransaction>

<cfinvoke component="#dataObj#" method="updateTable1" ..>

 

<cfinvoke component="#dataObj#" method="deleteTable2" .>

<cfloop from="1" to="#something# index="i">

<cfif this EQ that>

<cfinvoke component="#dataObj#" method="insertTable2" .>

<cfelse>

<cfinvoke component="#dataObj#" method="updateTable2" .>

</cfif>

</cfloop>

</cftransaction>

 

Will the <cftransaction> work here allowing all these queries to be rolled back if any where to fail?

--------------
Ian Skinner
Web Programmer
BloodSource
www.BloodSource.org
Sacramento, CA

"C code. C code run. Run code run. Please!"
- Cynthia Dunning

 

Confidentiality Notice: This message including any attachments is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender and delete any copies of this message.

Reply via email to