From: | Andrew Rawnsley <ronz(at)ravensfield(dot)com> |
---|---|
To: | Anton(dot)Nikiforov(at)loteco(dot)ru |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Hierarchical queries |
Date: | 2004-01-09 19:16:14 |
Message-ID: | 4ABF0C8A-42D8-11D8-9B94-000393A47FCC@ravensfield.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
There's a patch to mimic Oracle's CONNECT BY queries. You can get it
at the Postgres Cookbook site:
http://www.brasileiro.net/postgres/cookbook.
(although it seems to be down at the moment...)
On Jan 9, 2004, at 2:05 PM, Anton(dot)Nikiforov(at)loteco(dot)ru wrote:
> Hello everybody!
>
> Does someone know how to build hierarchical queries to the postgresql?
>
> I have a table with tree in it (id, parent)
> and need to find a way from any point of the tree to any other point.
> And i would like to have a list of all steps from point A to point B
> to make some changes on each step (this is required by the algorythm).
>
> Here is an example:
> treetable (where tree is stored):
> id parent data
> int4 int4 varchar(255)
> 0 0 root
> 1 0 root's chield 1
> 2 0 root's chield 2
> 3 1 root's chield 1 chield 1
> 4 1 root's chield 1 chield 2
> 5 2 root's chield 2 chield 1
> 6 2 root's chield 2 chield 2
>
> And i want to get something like this:
> start point "root's chield 2 chield 2"
> finish "root's chield 1 chield 1"
>
> And the result i need:
> id parent data
> 6 2 root's chield 2 chield 2
> 2 0 root's chield 2
> 0 0 root
> 1 0 root's chield 1
> 4 1 root's chield 1 chield 2
>
> i know that it is possible in Oracle but what about postgres?
>
> Best regards,
> Anton Nikiforov
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
>
--------------------
Andrew Rawnsley
President
The Ravensfield Digital Resource Group, Ltd.
(740) 587-0114
www.ravensfield.com
From | Date | Subject | |
---|---|---|---|
Next Message | Christopher Browne | 2004-01-09 19:27:12 | Re: full db locking during dump |
Previous Message | Anton.Nikiforov | 2004-01-09 19:05:06 | Hierarchical queries |