From: Roy Goldhammer on
Hello there

have system where each client has owner and there is racursive query i've
created that returns all client childs by using with.

One of my users by mistake entered in child one of previous owners and it
crashed the racursive.

Is there a way in with racursive not get childs who have already been
chosen?


From: Stefan Hoffmann on
hi Roy,

On 03.08.2010 13:58, Roy Goldhammer wrote:
> One of my users by mistake entered in child one of previous owners and it
> crashed the racursive.
Then you must have a design flaw in your table structure.

> Is there a way in with racursive not get childs who have already been
> chosen?
How can we tell without further information, but a guess: Yes, there
seems to be a way...

btw, it's a recursive or hierarchic structure.


mfG
--> stefan <--
From: Roy Goldhammer on
Whell Stefan:

I'm using with racursive to do it

My table looks like Clients(ClientID int
, Parent_client int)

which Parent_Client is the father of the client

My table data looks like this:

ClientID, Parent_Client
1, null
2, 1
3, 1
4, 2
5, 8 -- the error here because it cause loop.
6, 5
7, 6
8, 7

is there a way using with racursive not to make loop?
"Stefan Hoffmann" <ste5an(a)ste5an.de> wrote in message
news:%23OEb$oxMLHA.5700(a)TK2MSFTNGP04.phx.gbl...
> hi Roy,
>
> On 03.08.2010 13:58, Roy Goldhammer wrote:
>> One of my users by mistake entered in child one of previous owners and it
>> crashed the racursive.
> Then you must have a design flaw in your table structure.
>
>> Is there a way in with racursive not get childs who have already been
>> chosen?
> How can we tell without further information, but a guess: Yes, there seems
> to be a way...
>
> btw, it's a recursive or hierarchic structure.
>
>
> mfG
> --> stefan <--


From: --CELKO-- on
This is called an adjacency list model. You will need to add triggers
and/or constraints to the DDL.

Google the Nested sets model; it does not have have these problems.
You can also get a copy of TREES & HIERARCHIES IN SQL for the code and
other methods of modeling tree structures in SQL.

From: Tony Rogerson on


"--CELKO--" <jcelko212(a)earthlink.net> wrote in message
news:041651bc-e687-4782-81bc-a5ac9c32018e(a)x21g2000yqa.googlegroups.com...
> This is called an adjacency list model. You will need to add triggers
> and/or constraints to the DDL.
>
> Google the Nested sets model; it does not have have these problems.
> You can also get a copy of TREES & HIERARCHIES IN SQL for the code and
> other methods of modeling tree structures in SQL.
>

The nested sets model requires complex procedural trigger code to maintain,
it also badly suffers from concurrency problems for frequently changing
hierarchies.

--ROGGIE--