Re: Pure SQL transitive closure with LEVEL
From: Sagi <sag1rk_at_yahoo.com>
Date: 28 Nov 2002 09:38:49 -0800
Message-ID: <54d80104.0211280938.3a2955ce_at_posting.google.com>
Date: 28 Nov 2002 09:38:49 -0800
Message-ID: <54d80104.0211280938.3a2955ce_at_posting.google.com>
gerg_at_ncom.ru (Serg) wrote in message news:<a9680411.0211250445.267a3c8f_at_posting.google.com>...
> Hi
>
> I need pure SQL code to compute transitive closure from adjacency
> matrix, say table X(ParentID, ChildID). I managed to compute all
> ancestor/predecessor pairs, but couldn't
> find the way to get a distance (level) between them in same query.
>
> Any ideas?
>
> regards
> Serg Levin
> gerg_at_ncom.ru
Hi,
Is this what you are looking for:
select RPAD('-',level*2,'-') || ENAME
FROM EMP
START WITH MGR IS NULL
CONNECT BY PRIOR EMPNO=MGR
execute and see the output.
Regards,
Sagi
Received on Thu Nov 28 2002 - 18:38:49 CET