contrib/ltree might be of use to you.
On Nov 14, 2006, at 3:46 PM, Eric E wrote:
We're trying to use connectby to transform a tree into an ordered
set of rows, specifically requirements rows.
We have data stored in a table with
keyid and parent_id, as described in the examples for
keyid is
Eric E wrote:
However, we would like to return a numbering the items based on the
order they return, like so;
1 (first item)
1.1 (1 branch, 1st item)
1.2 (1 branch, 2nd item)
1.2.1 (1.2 branch, 1st item)
1.2.2
1.2.2.1
1.3
etc.
Is there an option in connectby to do this directly, or do we n
Hi all,
We're trying to use connectby to transform a tree into an ordered set
of rows, specifically requirements rows.
We have data stored in a table with
keyid and parent_id, as described in the examples for
keyid is also the primary key of a table A, which has the field
A.seq_number.
We
Joe Conway wrote:
--without patch
regression=# SELECT * FROM connectby('connectby_bytea', 'keyid',
'parent_keyid', 'row\\134', 0, '') AS t(keyid bytea, parent_keyid bytea,
level int, branch text);
ERROR: invalid input syntax for type bytea
--with attached patch
regression=# SELECT * FROM connec
David Garamond wrote:
Now that I enter as an escaped string, I get this error:
db1=> SELECT * FROM connectby('treeadj1b', 'id', 'parent_id',
'\\353\\024\\257\\130\\336\\305\\061\\045\\276\\175\\106\\056\\101\\173\\217\\326',
0) AS t(keyid bytea, parent_keyid bytea, level int);
ERROR: invalid in
Joe Conway wrote:
regression=# SELECT * FROM connectby('connectby_bytea', 'keyid',
'parent_keyid', 'row\\002', 0, '') AS t(keyid bytea, parent_keyid bytea,
level int, branch text);
Oh, I was specifying the fourth argument in BYTEA (decode('hex...','hex')).
Now that I enter as an escaped string,
> hi
>
> I have menu table:
> id | integer | not null default
> nextval('public.menu_id_seq'::text)
> parent_id | integer |
> description | text|
>
> I do select:
> test=> SELECT * FROM connectby('menu','id','parent_id','2',0,'~') t(id
> integer, parent_id integer, level in