2009/2/6 Michael Mraka <[email protected]>
>
> CONNECT BY creates a "tree select". Can the above select with
> rhn_get_action_prerequisites() handle multi level dependencies as well?
> I.e. for
> id prerequisite
> 1 NULL
> 2 1
> 3 1
> 21 NULL
> 22 21
> 23 22
> the result of
> select id
> from rhnAction
> start with id = 21
> connect by prior id = prerequisite
> is
> 21
> 22
> 23
Thats the whole point!
Yes, this implementation caters to the need of traversing hierarchical data.
I had tried and failed to create a generic CONNECT BY replacement. So,
looking at the current usage, I have created these functions. These
functions cater only to the cases I see in the code, and will not handle any
new tables (new solutions can be modeled based on this though)
Following are the three queries (with their output) from the file attached
previously:
postgres=# select lpad( id, level*2 ), prerequisite from
rhn_get_action_prerequisites( 1 ) as f( id numeric, prerequisite numeric,
level int);
lpad | prerequisite
----------+--------------
1 |
2 | 1
6 | 2
7 | 6
3 | 1
8 | 3
(6 rows)
postgres=# select lpad( id, level*2 ), prerequisite from
rhn_get_action_prerequisites( 2 ) as f( id numeric, prerequisite numeric,
level int);
lpad | prerequisite
--------+--------------
2 | 1
6 | 2
7 | 6
(3 rows)
postgres=# select lpad( id, level*2 ), prerequisite from
rhn_get_action_prerequisites( 4 ) as f( id numeric, prerequisite numeric,
level int);
lpad | prerequisite
------+--------------
4 |
5 | 4
(2 rows)
postgres=#
Hope this answers your question.
Best regards,
--
gurjeet[[email protected]
EnterpriseDB http://www.enterprisedb.com
singh.gurj...@{ gmail | hotmail | indiatimes | yahoo }.com
_______________________________________________
Spacewalk-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/spacewalk-devel