Putting each individual query into it's own file and then including the files wherever needed is the route I'd go. You could use a CFC, if you wanted, but only if you did the 6.1 update, as 6.0 had issues with method calls and CFTRANSACTION. However, throwing a CFC into the mix is probably foolhardy, unless you're already using CFCs throughout, since it would make that one set of DB interactions work totally different from all the others.
barneyb --- Barney Boisvert, Senior Development Engineer AudienceCentral [EMAIL PROTECTED] voice : 360.756.8080 x12 fax : 360.647.5351 www.audiencecentral.com > -----Original Message----- > From: Ian Skinner [mailto:[EMAIL PROTECTED] > Sent: Tuesday, September 09, 2003 10:53 AM > To: CF-Talk > 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

