R
RJN
Hi
I need help in writing a recursive function. My table structure is as
below.
InstanceId LevelId ParentId
100 1 null
101 2 100
102 3 101
103 4 102
104 5 103
105 5 104
106 5 104
From the above example, 100 is the root node which has a child 101, 101
has a child 102 and so on. Given a instanceid I want to get all the
child below that having levelid = 5. So if I give InstanceId=100, then I
should get a list of 104, 105, 106. If I pass the instance id 104, then
I should get 105 and 106. How I can I write a recursive function for
this?
Also I want to construct the xml tree structure. So passing in Instance
Id, I should get the immediate child below that and so on. If instance
id is 100, then there should be one leaf node 101 which will have
another leaf node 102 and so on. Can anyone help me?
Thanks
rjn
I need help in writing a recursive function. My table structure is as
below.
InstanceId LevelId ParentId
100 1 null
101 2 100
102 3 101
103 4 102
104 5 103
105 5 104
106 5 104
From the above example, 100 is the root node which has a child 101, 101
has a child 102 and so on. Given a instanceid I want to get all the
child below that having levelid = 5. So if I give InstanceId=100, then I
should get a list of 104, 105, 106. If I pass the instance id 104, then
I should get 105 and 106. How I can I write a recursive function for
this?
Also I want to construct the xml tree structure. So passing in Instance
Id, I should get the immediate child below that and so on. If instance
id is 100, then there should be one leaf node 101 which will have
another leaf node 102 and so on. Can anyone help me?
Thanks
rjn