Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Again tree

Posted on 2004-03-30
11
Medium Priority
?
1,414 Views
Last Modified: 2013-12-12
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
0
Comment
Question by:Solve
  • 7
  • 4
11 Comments
 
LVL 1

Author Comment

by:Solve
ID: 10713201
How to find a node, to witch I want to add more nodes?

Solveiga
0
 
LVL 6

Expert Comment

by:musdu
ID: 10713488
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
 
LVL 1

Author Comment

by:Solve
ID: 10713669
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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 6

Expert Comment

by:musdu
ID: 10714100
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
 
LVL 1

Author Comment

by:Solve
ID: 10721058
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
 
LVL 1

Author Comment

by:Solve
ID: 10721164
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
 
LVL 6

Accepted Solution

by:
musdu earned 200 total points
ID: 10721338
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
 
LVL 1

Author Comment

by:Solve
ID: 10721481
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
 
LVL 1

Author Comment

by:Solve
ID: 10721491
Could you please say me one more think? How?

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

Solve
0
 
LVL 6

Expert Comment

by:musdu
ID: 10721562
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
 
LVL 1

Author Comment

by:Solve
ID: 10721604
Thanks again:)

You rescued me!!!!!!

Solve
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
Suggested Courses

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question