Hey Ian,

Your approach with includes is what I use ( I never put queries directly in
a display file...always include for re-use)....anything beyond that is
overkill in this situation IMHO.

Why do you use this block?:
<cfif Success>
<cftransaction action="commit"/>
<cfelse>
<cftransaction action="rollback"/>
</cfif>

That is what CFTRANSACTION does by default AFAIK (and from wacthing what
happens in the DB upon failures)...if any query fails all database changes
get rolled back....if not they all get committed....does anybody think/know
different?

Bryan Stevenson B.Comm.
VP & Director of E-Commerce Development
Electric Edge Systems Group Inc.
t. 250.920.8830
e. [EMAIL PROTECTED]

---------------------------------------------------------
Macromedia Associate Partner
www.macromedia.com
---------------------------------------------------------
Vancouver Island ColdFusion Users Group
Founder & Director
www.cfug-vancouverisland.com
----- Original Message -----
From: "Ian Skinner" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Tuesday, September 09, 2003 10:53 AM
Subject: Complex <cftransaction> constructions.


> Ok, I've got a <cftransaction> construct such as the pseudo code below.
>
> <cftransaction action="begin">
> <cfquery name=one/>
>
> <cfquery name=two/>
>
> <cfquery name=three/>
>
> <cfquery name=four/>
>
> <cfif Success>
> <cftransaction action="commit"/>
> <cfelse>
> <cftransaction action="rollback"/>
> </cfif>
> </cftransaction>
>
> The problem is that I have over a dozen transaction sets like this where
> only query two changes, the other three are the same.  In the interest of
> code reuse, and my personal sanity, I would like to somehow use common
code
> for the three unchanging queries.  I'm wondering what is the best way to
do
> this?
>
> What is most important is that all the queries succeed or fail as a group.
> It would be very bad for the database if query one and two succeeded and
> input data into the database, but query three fails and query four is not
> even tried because of the failure.
>
> The idea one I'm most confident will work, but is it really the best?
> <cftransaction action="begin">
> <cfinclude template=query_one.cfm>
>
> <cfinclude template=query_two.cfm>
>
> <cfinclude template=query_three.cfm>
>
> <cfinclude template=query_four.cfm>
>
> <cfif Success>
> <cftransaction action="commit"/>
> <cfelse>
> <cftransaction action="rollback"/>
> </cfif>
> </cftransaction>
>
> Are there any other ways to do this?  Could one somehow use custom tags or
> components?  Would these actually be better even if they are useable?
> <cftransaction action="begin">
> <cf_queryOne>
>
> <cf_queryTwo>
>
> <cf_queryThree>
>
> <cf_queryFour>
>
> <cfif Success>
> <cftransaction action="commit"/>
> <cfelse>
> <cftransaction action="rollback"/>
> </cfif>
> </cftransaction>
>
> OR
>
> <cftransaction action="begin">
> <cfinvoke component=query method=one>
>
> <cfinvoke component=query method=two>
>
> <cfinvoke component=query method=three>
>
> <cfinvoke component=query method=four>
>
> <cfif Success>
> <cftransaction action="commit"/>
> <cfelse>
> <cftransaction action="rollback"/>
> </cfif>
> </cftransaction>
>
> Is there an entirely another way to be thinking about this problem?
> Something that is simple and straightforward that I'm overlooking?
>
> Thanks
>
> --------------
> Ian Skinner
> Web Programmer
> BloodSource
> www.BloodSource.org
> Sacramento, CA
>
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. 
http://www.fusionauthority.com/ads.cfm

Reply via email to