Um, how about something like this? (Untested)

<cfset parents = "3"> <!--- the id of the ancestor --->

<cfset notDone=true>

<cfloop condition="#notDone#">

            <cfquery name="children">

                        SELECT         id

FROM               myTable
            WHERE            parent in (#parents#)

            </cfquery>

            <cfquery>

                        DELETE

FROM               myTable
            WHERE            parent in (#parents#)

            </cfquery>

            <cfif children.recordCount>

                        <cfset parents = valueList(children.id)>

            <cfelse>

                        <cfset notDone = false>

            </cfif>

</cfloop>



  _____  

From: Qasim Rasheed [mailto:[EMAIL PROTECTED]
Sent: Thursday, 19 August 2004 3:09 p.m.
To: CF-Talk
Subject: Re: Access SQL Question

I want to recursively delete descendants at all levels. Any thoughts?

----- Original Message -----
From: Matthew Walker <[EMAIL PROTECTED]>
Date: Thu, 19 Aug 2004 10:25:19 +1200
Subject: RE: Access SQL Question
To: CF-Talk <[EMAIL PROTECTED]>

Is this what you want?

DELETE

FROM               myTable

WHERE            parent = 3

Or do you want to be able to recursively delete descendents (i.e. children,
cgrandchildren.) at all levels?

  _____  

From: Qasim Rasheed [mailto:[EMAIL PROTECTED]
Sent: Thursday, 19 August 2004 8:32 a.m.
To: CF-Talk
Subject: Access SQL Question

Is there a way in access where you can delete all the child of a
parent e.g. if I am deleting a record which a children and
children(s) may or may not have child. Here is db schema

id,name,parent
1,test1,0
2,test2,0
3,test3,1
4,test4,3

any help is appreciated

  _____________________________________

  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to