Hi,
Am Mittwoch, 08. Aug 2007, 00:52:41 +0200 schrieb Bertram Scharpf:
> <http://www.bertram-scharpf.de/tmp/connectby.tar.gz>
I just extended it. Below an example.
Bertram
--------------------------------
select * from simp;
id | pid | nam
----+-----+----------
1 | | Abe
2 | 1 | Homer
3 | 2 | Bart
4 | 2 | Lisa
5 | 2 | Maggie
6 | | Ned
7 | 6 | Rod
8 | 6 | Todd
9 | | Clancy
10 | 9 | Ralph
11 | | Hyman
12 | 11 | Herschel
(12 rows)
select repeat(' ',t.lev)||(case when t.term then '`' else '|' end)||'-'||s.nam
from connectby_all( 'simp', 'id', 'pid', 'nam asc', null, null)
as t (id integer, pid integer, lev integer, pos integer, term boolean)
join simp as s on (t.id=s.id);
?column?
----------------
|-Abe
`-Homer
|-Bart
|-Lisa
`-Maggie
|-Clancy
`-Ralph
|-Hyman
`-Herschel
`-Ned
|-Rod
`-Todd
(12 rows)
--
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de
---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match