I was wondering if there are any guidelines regarding cftransaction across
multiple functions in a cfc?
ex:
<cfcomponent>
<cffunction name="f1"...>
<!---do some initialization here --->
<cftransaction action = "begin">
<!--- call another cfc method that performs database
interactions--->
<cfset rt = f2 (arg1, ...)>
<cfif rt eq 1>
<cftransaction action = "rollback"/>
<cfreturn 1>
</cfif>
<!--- if everything Ok continue with the transaction--->
<cfset rt = f3 (arg1, ...)>
<cfif rt eq 1>
<cftransaction action = "rollback"/>
<cfreturn 1>
</cfif>
<!--- OK--->
<!--- do some more db stuff --->
<cftransaction action = "commit"/>
</cftransaction>
<cfreturn 0>
</cfunction>
<cffunction name="f2"...>
<cftry>
<cfquery 1>
......
</cfquery>
<cfquery 2>
.....
</cfquery>
<cfcatch type = "database">
<cfreturn 1>
</cfcatch>
</cftry>
</cffunction>
</cfcomponent>
Each of the above function is doing some database updates/inserts that are
surrounded by <cftry><cfcatch>
that will return an error code to the main function which is doing the
rollback.
The above doesn't work as expected allowing partial commits. So if a db
error happens in the f2 at the second <cfquery 2> the first <cfquery 1>
actually update the database instead of rolling back .
It seems that the transaction is not seen in the called functions and as
such each cfquery in the those functions are on their own and not part of a
transaction.
Any pointers are appreciated.
thanks
Marius Milosav
www.scorpiosoft.com
It's not about technology, it's about people.
Virtual Company (VICO) Application Demo
www.scorpiosoft.com/vicodemo/login.cfm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm