Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Oracle Miscellaneous > Hierarchical Su...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 9 Topic 6838 of 7039
Post > Topic >>

Hierarchical Subquery must omit nodes

by "Chris L." <diversos@[EMAIL PROTECTED] > Apr 16, 2008 at 10:16 AM

Hi all,

I thought this would be easy but it's turning out to be pretty
difficult.

I need a hierarchical query to omit nodes present in a EXCLUDED_NODES
table.
Omitted nodes' children should be omitted too.

See this example taken from
http://download.oracle.com/docs/cd/B10501_01/server.920/a96540/functions121a.htm#88362

SELECT LPAD(' ', 2*level-1)||SYS_CONNECT_BY_PATH(last_name, '/')
"Path"
   FROM employees
   START WITH last_name = 'Kochhar'
   CONNECT BY PRIOR employee_id = manager_id;

Path
---------------------------------------------------------------
 /Kochhar
   /Kochhar/Greenberg
     /Kochhar/Greenberg/Faviet
     /Kochhar/Greenberg/Chen
     /Kochhar/Greenberg/Sciarra
     /Kochhar/Greenberg/Urman
     /Kochhar/Greenberg/Popp
   /Kochhar/Whalen
   /Kochhar/Mavris
   /Kochhar/Baer
   /Kochhar/Higgins
     /Kochhar/Higgins/Gietz

If I have Greenberg in EXCLUDED_NODES then output should be

Path
---------------------------------------------------------------
 /Kochhar
   /Kochhar/Whalen
   /Kochhar/Mavris
   /Kochhar/Baer
   /Kochhar/Higgins
     /Kochhar/Higgins/Gietz

Excluded node can be in any depth of the hierarchy (i.e. it could be
Gietz and then Gietz and all of its dependent sub-tree should be
pruned)

I've tried filtering the START WITH and works great but doesn't help
when the excluded node is somewhere deep in the hierarchy.

I've tried filtering the CONNECT BY but it cannot contain subqueries
(manual states this).

I've tried using the SYS_CONNECT_BY_PATH to parse it and see if it
contains an excluded node but I got an Ora-00600 error.

ORA-00600: internal error code, arguments: [rworupo.2], [26670], [1],
[], [], [], [], []

Oracle version is 9i

Thanks in advance!
Chris
 




 9 Posts in Topic:
Hierarchical Subquery must omit nodes
"Chris L." <  2008-04-16 10:16:42 
Re: Hierarchical Subquery must omit nodes
"fitzjarrell@[EMAIL   2008-04-16 11:17:57 
Re: Hierarchical Subquery must omit nodes
Urs Metzger <urs@[EMAI  2008-04-16 20:45:43 
Re: Hierarchical Subquery must omit nodes
"Shakespeare" &  2008-04-16 21:21:32 
Re: Hierarchical Subquery must omit nodes
"fitzjarrell@[EMAIL   2008-04-16 12:57:00 
Re: Hierarchical Subquery must omit nodes
Urs Metzger <urs@[EMAI  2008-04-16 23:43:36 
Re: Hierarchical Subquery must omit nodes
"Chris L." <  2008-04-17 08:09:48 
Re: Hierarchical Subquery must omit nodes
"fitzjarrell@[EMAIL   2008-04-17 08:45:32 
Re: Hierarchical Subquery must omit nodes
"fitzjarrell@[EMAIL   2008-04-17 08:54:13 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Thu Jul 24 5:58:15 CDT 2008.