Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Again tree

Posted on 2004-03-30
11
Medium Priority
?
1,413 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

722 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