Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hierarchial Delete - From Parent delete of all the Children

Status
Not open for further replies.

saiza

Programmer
Apr 26, 2002
24
0
0
IN
hello guys,

Scenario::
I have one parent Task P1 which has children C1 and C2. Now C1 has two more childres C1G1 and C1G2.

If i delete P1, I should be able to delete C1 and C2 and also children of C1 - C1G1 and C1G2.

How can I manage this in Java. Right now I ask the user to delete the subtasks before deletign the parent task.

I have a table where in I have a parent Id for each chuld in one table, another table has other details of all the tasks.

Can somebody help please !!!!

Thanking you in advance

 
Heres a recursive function in pseudocode to do that:

delete(int id) {
int array[] kids = get all children
for x = 0 to kids.length
if (kids[x] has no children)
find info on kids[x] and delete it
else
get the parent id of kids[x]
delete(id)
end for
delete this parent
}
[morning] HavaTheJut
 
hi...

Can I have a stored procedure for this.... How do I write for the above scenario...

Pretty urgent ...can somebody help plz

saiza
 
From a niceprogram dseign point of view, check out the Composite Model paradigm for java prgramming, theres quite a few good places on google.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top