Hello,
I have a hierachy of groups modelled as a nested set. Like Joe Celko does it in his book "Trees and hierachies in SQL for smarties".
I have a problem creating a query that will insert a new node at the rightmost position under a given parent node.
If I have the tree:
Code:
node1
/ | \
/ | \
/ | \
node2 node3 node4
|
node5
I want to insert a new node6 here:
Code:
node1
/ | | \
/ | | \
/ | | \
node2 node3 node4 node6
|
node5
In Celkos book, he gives a procedure that would add the new node, given the parent node (node1), as a sibling to node4. And another procedure that would add the new node to the right of a given sibling (node4). That approach is close to what I need, but I need to add it using the parent node.
Anyone who has a procedure that can help me do that?
Thanks in advance!