|
Posted by --CELKO-- on 10/01/71 11:58
>> Here is the code to flatten a PC hierarchy into a level based table. <<
I am not sure what a "level based table" is and you did not bother to
post DDL. I am guessing you mean that you have an adjacency list model
for your hierarchy.
>> How do modify the code to work for any level rather than hard coding the level up to "5"? <<
One kludge is dynamic SQL. A table BY DEFINITION has a fixed number of
columns.
A seocnd kludge is a recursive CTE (watch for cycles!!) that builds a
concatenated string.
The right answer is that display is done in the front end and never in
the back end in a tiered archtiecture.
You might also want to get a copy of TREES & HIERARCHIES IN SQL for
toher ways to model these problems.
Navigation:
[Reply to this message]
|