Solved

# Again tree

Posted on 2004-03-30
1,393 Views
Hello, I came back with my question about hierarchical tree.

htree := Find_item('MyTree');

Ftree.root_node,                                                                        Ftree.parent_offset,                                                                      Ftree.last_child,
Ftree.expanded_node, 'Aerodromai',null,'Aero');

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

Solveiga
0
Question by:Solve
• 7
• 4

LVL 1

Author Comment

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

Solveiga
0

LVL 6

Expert Comment

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

ID: 10713669
But you know, I don't if I add data like this:

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

LVL 6

Expert Comment

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

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

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

musdu earned 50 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
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

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

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

ID: 10721562

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

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

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

ID: 10721604
Thanks again:)

You rescued me!!!!!!

Solve
0

## Featured Post

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.