Gurjeet Singh wrote:
% Hi All,
% 
%     As I mentioned in the last conference call, I could not implement a
% workaround for CONNECT BY in plpgsql; that was because of a limitation in
% the way plpgsql handles the pseudo datatype RECORD.
...
% and both these instances SELECT the same data: given an action_id, give me
% all the pre-requisites in order.
% 
% So I have written two plpgsql functions to accomplish what these two
% instances need. Please find the code and a few examples attached.
% 
% Using these functions, the queries can now be written as:
% 
% ./backend/server/rhnAction.py:
% 
% _query_lookup_action = rhnSQL.Statement("""
%     select sa.action_id, sa.status
%       from rhnServerAction sa,
%          (
%           select id
%             from rhn_get_action_prerequisites( :action_id )
%                       as f( id numeric, prerequisite numeric, level int)
%            /**** start with id = :action_id
%                  connect by prior id = prerequisite ****/
%          ) a
%      where sa.server_id = :server_id
%        and sa.action_id = a.id
% """)

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
.               
        


--
Michael Mráka
Satellite Engineering, Red Hat

_______________________________________________
Spacewalk-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to