Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: HOWTO ORDER HIERARCHICAL QUERIES ?

Re: HOWTO ORDER HIERARCHICAL QUERIES ?

From: Kai Poitschke <kai.poitschke_at_computer.org>
Date: Mon, 13 Sep 1999 23:14:43 +0200
Message-ID: <37DD6943.9E80C0A8@computer.org>


Jan Rosinowski wrote:
>
> >order by level,org_chart
>
> doesn't work as the author correctly stated.

I received a private email with the solution, but I think the answer is of public interest. Thanks Mark.

You have to use hint.

create index i_emp_mgr_ename on emp(mgr,ename);

SELECT /*+ INDEX(emp i_emp_mgr_ename) */ --this hint enforces fetching rows by index from table.
LPAD(' ',2*(LEVEL-1)) || ename org_chart,

        empno, mgr, job
    FROM emp
    START WITH job = 'PRESIDENT'
    CONNECT BY PRIOR empno = mgr;

Mark

In reality my problem is a bit more complex, because the user can choose between two sort criteria. I used two indexes and dynamic pl/sql to execute the statement.

Thanks All

Kai
--
$f

Unix, WinNT and MS-DOS. The Good, The Bad and The Ugly. Kai Poitschke MailTo:kai.poitschke[at]computer.org Date/Time: $d/$t Received on Mon Sep 13 1999 - 16:14:43 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US