Again tree

Hello, I came back with my question about hierarchical tree.

htree := Find_item('MyTree');
      
new_node := Ftree.Add_tree_node(htree,
                  Ftree.root_node,                                                                        Ftree.parent_offset,                                                                      Ftree.last_child,
                  Ftree.expanded_node, 'Aerodromai',null,'Aero');
 
   Ftree.Add_Tree_Data(htree,      new_node,
                                      Ftree.PARENT_OFFSET,
                     Ftree.LAST_CHILD,
                     Ftree.QUERY_TEXT,
                     'SELECT 0, 1, AERO_PAV, NULL, to_char(AERO_ID) FROM T_AERO' );

And my question is:

I need to add some more nodes in the same level (not parent, but his child) how to get that valid node witch is added child and
add more data?

Please help me

Solveiga
LVL 1
SolveAsked:
Who is Participating?
 
musduConnect With a Mentor Commented:
Goodmorning,

I think mydata1 represents AERO_ID in this example? I do not know name of your other table but let's say MYTABLE (having columns AERO_ID and UNIT)


DECLARE

   htree   ITEM;
   find_node FTREE.NODE;
   
BEGIN

-- Find tree

htree := Find_item('MyTree');

-- We need to find nodes

FOR vMyTable IN (SELECT DISTINCT AERO_ID IN MYTABLE) LOOP

   find_node := Ftree.Find_Tree_Node(
      htree,
      vMyTable.Aero_Id,
      Ftree.FIND_NEXT,
      Ftree.NODE_VALUE,
      Ftree.ROOT_NODE,
      Ftree.ROOT_NODE);

   -- We found the node

   IF NOT Ftree.ID_NULL(find_node) then
      Ftree.Add_Tree_Data(
         htree,
         find_node,
         Ftree.PARENT_OFFSET,
         Ftree.LAST_CHILD,
         Ftree.QUERY_TEXT,
         'SELECT 0, 1, UNIT, NULL, UNIT FROM MYTABLE WHERE ARO_ID ='||vMyTable.Aero_Id);
  END IF;

END LOOP;

END;




0
 
SolveAuthor Commented:
How to find a node, to witch I want to add more nodes?

Solveiga
0
 
musduCommented:
Solve,

Forms Builder help has a good example about finding a tree node;

/*  

** Built-in:  FIND_TREE_NODE
*/

-- This code finds a node with a label of "Doran"
-- within the subtree beginning with the a node
-- with a label of "Zetie".

DECLARE
   htree         ITEM;
   find_node     Ftree.NODE;
BEGIN
   -- Find the tree itself.
   htree := Find_Item('tree_block.htree3');


   -- Find the node with a label "Zetie".
   find_node := Ftree.Find_Tree_Node(htree, 'Zetie', Ftree.FIND_NEXT,
                 Ftree.NODE_LABEL, Ftree.ROOT_NODE, Ftree.ROOT_NODE);

   -- Find the node with a label "Doran"
   -- starting at the first occurance of "Zetie".
   find_node := Ftree.Find_Tree_Node(htree, 'Doran', Ftree.FIND_NEXT,
                Ftree.NODE_LABEL, find_node, find_node);

   IF NOT Ftree.ID_NULL(find_node) then
      ...
   END IF;
END;


0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
SolveAuthor Commented:
But you know, I don't if I add data like this:

  Ftree.Add_Tree_Data(htree,     new_node,
                                    Ftree.PARENT_OFFSET,
                  Ftree.LAST_CHILD,
                  Ftree.QUERY_TEXT,
                  'SELECT 0, 1, AERO_PAV, NULL, to_char(AERO_ID) FROM T_AERO' );
and I need to add a node exactly to that node with value is AERO_ID....

How can I find_node when I don;t know label? Could you help?

Solveiga
0
 
musduCommented:
Solve,

where do you want to add the data? Do you want to add a new node or new data under a node? I think your tree same as the below one?

Root
   MyNode1
          mydata1
          mydata2
          mydata3
   MyNode2
          mydata21
          mydata22
0
 
SolveAuthor Commented:
Good morning :)

Look there I want to add one more node:

Root
   MyNode1
          mydata1
               new_node
          mydata2
               new_node
          mydata3
               new_node
   MyNode2
          mydata21
          mydata22

Is it possible?

Solve
0
 
SolveAuthor Commented:
Yes yes, my tree looks exactly like you said
I create node with some new nodes:
MyNode1
MyNode2
then to MyNode1 I add data from one table
to MyNode2 I add data from second table and I have:

Root
   MyNode1
          mydata1
          mydata2
          mydata3
   MyNode2
          mydata21
          mydata22

And also I want to put some more information from my others table and I want to create nodes
Like (e.g. all units associated with my first node's data)
Units will be from third table witch is connected with my T_AERO via AERO_ID

Root
   MyNode1
     mydata1
        units
          unit1
          unit2
          unit3
          ...
     mydata2
        units
          unit1
          unit2
          unit3
          ...
   MyNode2
      mydata21
        units... (this would be the same like forst node, but not nessasary)

Is it possible to do that?
Solve
0
 
SolveAuthor Commented:
And I also need to add that node - units (from my example)
But now I think I will manage this with your help!!

Thank you very much, musdu

Solve
0
 
SolveAuthor Commented:
Could you please say me one more think? How?

I need to add this units to finded node as a new node?

Solve
0
 
musduCommented:
If you want to add them as new nodes instead of data use Add_Tree_Node built-in;


DECLARE

   htree   ITEM;
   find_node FTREE.NODE;
   
BEGIN

-- Find tree

htree := Find_item('MyTree');

-- We need to find nodes

FOR vMyTable IN (SELECT DISTINCT AERO_ID IN MYTABLE) LOOP

   find_node := Ftree.Find_Tree_Node(
      htree,
      vMyTable.Aero_Id,
      Ftree.FIND_NEXT,
      Ftree.NODE_VALUE,
      Ftree.ROOT_NODE,
      Ftree.ROOT_NODE);

   -- We found the node

   IF NOT Ftree.ID_NULL(find_node) then

      -- Add units as nodes

      FOR vUnits IN  (SELECT DISTINCT AERO_ID IN MYTABLE WHERE AERO_ID = vMyTable.Aero_Id) LOOP

         new_node := Ftree.Add_Tree_Node(htree,
                                   find_node,
                                   Ftree.PARENT_OFFSET,
                                   Ftree.LAST_CHILD,
                                   Ftree.EXPANDED_NODE,
                                   vMyTable.Unit,
                                   NULL,
                                  vMyTable.Unit);
       END LOOP;
 
END IF;

END LOOP;

END;


regards.
0
 
SolveAuthor Commented:
Thanks again:)

You rescued me!!!!!!

Solve
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.