S. Isaac Dealey wrote: > Before you give up... There's a couple of things you can do for the > recursion in the db... One is to create a cross-reference table which shows > the parent-child relationship between all records in the table... > Alternatively, you could try this: > > <cfset rs = QueryNew("ID")> > <cfset temp = QueryAddRow(rs)> > <cfset rs.id[1] = "0"> > <cfset rs2 = QueryNew("ID")> > > <cfloop condition="rs.recordcount"> > <cfquery name="rs" datasource="..."> > SELECT * FROM mytable > WHERE parentid IN (#valuelist(rs.id)#) > </cfquery><cfquery name="rs3" dbtype="query"> > SELECT * FROM rs UNION SELECT * FROM rs2 > </cfquery><cfset rs2 = rs3> > </cfloop> > > This or something like it ought to give you a single query containing all of > the children of the parent... It will be much slower than a cross-reference > table in the db, however, it should be similar in performance to the current > solution... Once you have this query, however, you can then use the > recursive UDF in CF 5 and either pass the query to the UDF along with the > current parent id for the tree, or you can place the query in the request > scope and reference it from there...
never do to much work in cf when your database can do it faster http://www.sqlteam.com/item.asp?ItemID=8866 is a really nice and simple method for doing trees.... it stores an id path for each node in your tree, automatically, that why you can do a query like (see example on page above) select node where lineage contains '/#target_node_id#' to return a specific part of the tree z > > > hth > > Isaac > Certified Advanced ColdFusion 5 Developer > > www.turnkey.to > 954-776-0046 > > >>All, > > >>Thank you for your responses to my inquiry. > > >>As it turns out, the CFSCRIPT option is not viable because >>the point of the recursion was querying a database for >>records that represented subordinate records which might >>have subordinate records of their own. > > >>The cfmodule seems to take forever and therefore is not >>practical. > > >>In the end, I will have to change the design of the >>application. However, that is not necessarily a bad >>thing. However, it does make me appreciate the changes in >>CFMX. > > >>Again, thank you all for your responses. > > > > >>---------- Original Message >>---------------------------------- >>From: Mosh Teitelbaum <[EMAIL PROTECTED]> >>Reply-To: [EMAIL PROTECTED] >>Date: Thu, 12 Sep 2002 15:45:57 -0400 > > >>>Or, you could rewrite the function without recursion. >>>Just thought I'd >>>mention it as another alternative. >>> >> > >>>-- >>>Mosh Teitelbaum >>>evoch, LLC >>>Tel: (301) 625-9191 >>>Fax: (301) 933-3651 >>>Email: [EMAIL PROTECTED] >>>WWW: http://www.evoch.com/ >>> >>> >>> >>>>-----Original Message----- >>>>From: Dave Watts [mailto:[EMAIL PROTECTED]] >>>>Sent: Thursday, September 12, 2002 2:23 PM >>>>To: CF-Talk >>>>Subject: RE: Recursion >>>> >>>> >>>> >>>>>I wrote this really neat recursive function using the >>>>><cffunction> tag on my development system which is >>>>>running >>>>>CFMX on WindowsXP Pro. When I ported to the >>>>>operational host >>>>>(third party), I discovered that they were running a >>>>>previous >>>>>version of CF (I do not know which) which does not >>>>>support >>>>>the new tag. Does anybody know how to do recursion >>>>>without >>>>>the <cffunction> tag? >>>> >>>>If your recursive function is relatively simple, you can >>>>probably write it >>>>as a CF 5-compliant user-defined function, using >>>>CFSCRIPT. >>>>CFSCRIPT is a tag >>>>in which you can write CF commands using a >>>>JavaScript-like language, which >>>>uses the same syntax and control flow structures as >>>>JavaScript, but uses >>>>CFML operators and expressions. You can't use CFML tags >>>>within a CFSCRIPT >>>>tag, though, and CFSCRIPT doesn't support all the things >>>>you can do with >>>>CFML tags, such as querying a database. Keep in mind >>>>that the host would >>>>have to be using CF 5 or higher for this to work. >>>> >>>>Alternatively, you could write a recursive custom tag. >>>>However, >>>>this is the >>>>least desirable alternative, as custom tags don't >>>>provide any built-in >>>>ability to return values (you can write that ability >>>>into your >>>>code, though) >>>>and they tend to negatively affect performance. >>>>Nevertheless, if you need >>>>recursion and you're using a version of CF prior to 5, >>>>that's the only way >>>>you can do it within CFML. >>>> >>>>Dave Watts, CTO, Fig Leaf Software >>>>http://www.figleaf.com/ >>>>voice: (202) 797-5496 >>>>fax: (202) 797-5444 >>>> >>>> >>> >>__________________________________________________________ >>____________ >>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 >>FAQ: http://www.thenetprofits.co.uk/coldfusion/faq >>Archives: >>http://www.mail-archive.com/cf-talk@houseoffusion.com/ >>Unsubscribe: >>http://www.houseoffusion.com/index.cfm?sidebar=lists > > > > > ______________________________________________________________________ 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 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists