Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> A hierarchical query - how do I do
I have two tables TASKS and TASK_PREDECESSORS
CREATE TABLE TASKS
(
ID NUMBER NOT NULL, NAME VARCHAR2(200 BYTE) NOT NULL,PARENT_ID NUMBER
ID NAME PARENT_ID 1 A 2 a 1 3 b 1
CREATE TABLE TASK_PREDECESSORS
(
PREDECESSOR_ID NUMBER NOT NULL, SUCCESSOR_ID NUMBER NOT NULL);
PREDECESSOR_ID SUCCESSOR_ID 2 3
I am looking for a query that returns all tasks in an oder that holds the following:
(1) children before parents
(2) predecessors before successors
i.e. the data in the table should return [ a, b, A ] - it should also
generate an error or indicator
that detects a cycle.
I'm offering my apology ahead if this is a sheer waste of time for others. May be, I am missing something really obvious here and I'm still trying this.
Would really appreciate if anyone can offer a tip.
Thanks.
P.S. - This is not a homework. But yes, something I am working on.. Received on Fri Feb 17 2006 - 22:53:06 CST