On 12/13/05, Sean Corfield <[EMAIL PROTECTED]> wrote:
> On 12/12/05, Chris Velevitch <[EMAIL PROTECTED]> wrote:
> > On 12/13/05, Sean Corfield <[EMAIL PROTECTED]> wrote:
> > > Your tags don't match (i.e., they are not correctly nested). You
> > > cannot split a try/catch across multiple tag executions like that.
> > Yes, but how do I extend the cftransaction to do what I'm trying to
> > do? Does doing in CFX work?
>
> I'm pretty sure you can't... custom tags can execute code before and
> after the body (and the "end" execution has access to the *text* of
> the body) but you can't make a custom tag that acts like a <cfloop>
> and actually executes CFML code like that...
Actually, you can:-
<cfif thisTag.ExecutionMode IS "start">
<cfset lvCount=0>
<cfelse>
<cfset lvCount = lvCount+1>
<cfif lvCount le #attributes.count#>
<cfexit method="loop">
</cfif>
</cfif>
But that's not the problem. The problem is the cftry. You can't say:-
<cfif start>
<cftry>
<cfelse>
<cfcatch type>
</cfcatch>
</cftry>
<cfif>
because CF is be too clever for it's own good. This is because of the
absence of any explicit way of introducing a custom tag. Any cfm file
can be a custom tag. And so when CF parses such code, there is an
general rule that says, opening and closing tags must in the same
page. If there was a custom tag tag, then CF could handle that as
being a special case and be aware tags have the open tag in the custom
tag start and the closing tag in the custom tag end. This would remake
CF extremely powerful and extensible.
> The closest you could get would be:
>
> <cf_transaction retry="3" datasource="foo" name="fooSelect">
> .... some SQL here ...
> </cf_transaction>
>
> and have the end tag execution do everything (looping over a try/catch
> containing cfquery tags containing the SQL). Your SQL could be
> multiple statements (separated by, say, ; ) which your custom tag
> would split out into separate strings - and therefore separate cfquery
> tags. And then you'd have to synthesize cfqueryparam yourself... a lot
> of work...
>
> (credit to Ben Forta for most of that idea - he just happened to be
> online while I was trying to answer this!)
This idea has been suggested already and it will work for single
queries, but for complex multi-query transactions containing a mix of
selects, inserts, updates and deletes, it's a lot of work.
The only solution, so far, is to have a component to do the
transaction retrying and the transaction in an abstract method and
have the implementation of the transaction as an extension of the
component
<cfcomponent>
<cfunction name='doit'>
<cfargument name="retrycount">
<cfloop index="retry" from="1" to="#arguments.retrycount#">
<cftry>
<cfset theTransaction()>
<cfbreak>
<cfcatch type="database">
...
</cfctach>
</cftry>
</cfloop>
</cffunction>
</cfcomponent>
<cfcomponent extends="transaction">
<cffunction name="theTransaction">
....
</cffunction>
</cfcomponent>
or something to that effect.
Chris
--
Chris Velevitch
Manager - Sydney Flash Platform Developers Group
www.flashdev.org.au
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:226902
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54