Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL

Chapter 4: Nested Sets Model of Hierarch... > 4.4 Functions in the Nested Sets Mod... - Pg. 76

4.4 Functions in the Nested Sets Model 63 However, if you just need a column to use in a sort for output to a host language, then replace the subquery expression with "(A2.rgt - A2.lft) AS sort_col" and use an "ORDER BY sort_col" clause in a cursor. 4.3.5 Finding Relative Position Given two nodes, can you find their relative position in the hierarchy; that is, who is the subordinate of whom or are they in different subtrees of the hierarchy? SELECT CASE WHEN :first_member = :second_member THEN :first_member || ' is ' || :second_member WHEN O1.lft BETWEEN O2.lft AND O2.rgt THEN :first_member || ' subordinate to ' || :second_member WHEN O2.lft BETWEEN O1.lft AND O1.rgt THEN :second_member || ' subordinate to ' || :first_member ELSE :first_member || 'no relation to ' || :second_member END