Sunday, October 11, 2015

Oracle tree SET_TREE_PROPERTY

/* 

** Built-in:  SET_TREE_PROPERTY
*/

-- This code could be used in a WHEN-NEW-FORM-INSTANCE
-- trigger to initially populate the hierarchical tree
-- with data.

DECLARE
   htree         ITEM;
   v_ignore      NUMBER;
   rg_emps       RECORDGROUP;
BEGIN
   -- Find the tree itself.
   htree := Find_Item('tree_block.htree3');

   -- Check for the existence of the record group.
   rg_emps := Find_Group('emps');
   IF NOT Id_Null(rg_emps) THEN
      DELETE_GROUP(rg_emps);

   END IF;

   -- Create the record group.
   rg_emps := Create_Group_From_Query('rg_emps',
             'select 1, level, ename, NULL, to_char(empno) ' ||
             'from emp '                                     ||
             'connect by prior empno = mgr '                 ||
             'start with job = ''PRESIDENT''');

   -- Populate the record group with data.
   v_ignore := Populate_Group(rg_emps);

   -- Transfer the data from the record group to the hierarchical

   -- tree and cause it to display.
   Ftree.Set_Tree_Property(htree, Ftree.RECORD_GROUP, rg_emps);
END;

1 comment: