>Hi guys!
>
>I have this situation: I have self-related table and want to delete a record X and all the records below it.
>Example:
>
>these are the records in my table:
>
>Employee - Boss
>******** ********
>Bill .Null.
>Joe Bill
>Mark Joe
>John Mark
>Peter Joe
>Paul John
>
>So, I have this logical structure:
>
>Bill
> |__Joe
> |__Mark
> | |__John
> | |__Paul
> |__Peter
>
>I want that, when I delete Joe, Mark, John, Paul and Peter get deleted too!
>
>I thought about 2 ways of doing that: the first one is a recursive function, where I would first "walk" and after delete (the deletion order would be paul, John, Mark, Peter and Paul). The other way (which i don't know if may work) is to create a trigger for the delete event on the table, but with this one I am not getting the idea.
>
>Please, which one is better? Can you explain and give an example?
>
>TIA,
>
>Alonso
Trigger could not be recursive, so you're limited to the first idea... It's a kind of exercise, which is discussed in any book on C++...
If it's not broken, fix it until it is.
My Blog