Recusive Hierachy

  • Joe, your code had the same results as Jeff's. Here's the first 12 rows of 279 in my Stack. The Rights don't appear to correspond to the model. The first entry in the Stack is the top-most manager. His Left should be (and is) 1 and his Right should be (but isn't) the maximum of all his subordinates' Rights+1, right? It's not even close. The Rights of his subordinates are higher than his Right, and the Rights of the last few below who have no subordinates are all the same.

    There are 279 entries in the Stack. The Max(Left) is 555, the Rights start at 560 and only go to 565. I know there are six levels to the organization so there seems to be some correlation there, but this clearly doesn't follow the original model in the article...

    ID        Left    Right

    225663     1      560

    110219     2      561

    114068     3      562

    121417     5      562

    123836     6      563

    121865     9      562

    113782    10     563

    118544    11     564

    111302    12     565

    112470    14     565

    124699    16     565

    132788    18     565

     

  • When you say "error in your data" do you mean things like an orphan (no supervisor) or a supervisor ID that isn't in the #tree?

    That might explain things. I can certainly weed those out in my data source (use a view that excludes invalid supervisor relationships rather than the raw Employees table).

    I'll give that a try.

     

  • I made sure that the Tree has no orphans. Every node in the tree has a parent (execpt the top one) and that parent exists as a node in the tree. Here's what I got at the end:

    225663 1 589

    110219     2 589

    114068     3 589

    121417     5 589

    123836     6 589

    121865     9 589

    113782     10 589

    118544     11 589

    111302     12 589

    112470     14 589

    124699     16 589

    132788     18 589

    If you want I can stop the query after the stack is built and send you a ZIP of the stack in CSV format. It's only about 277 entries. Maybe you can figure out why it's not generating the Rights correctly. I'm absolutely stumped.

     

  • Did you two ever resolve this? Were there any changes to the code?

Viewing 4 posts - 16 through 18 (of 18 total)

You must be logged in to reply to this topic. Login to reply