A brief introduction of oracle| and tree
The Developer 6.0 version provides the concept of hierarchy tree (hierarchy trees), the Htree control is very convenient, only need a small amount of programming to achieve the purpose of the display hierarchy.
The following are important in the tree's unique properties:
L multiple selection (multi-selection): Whether multiple nodes of the tree are allowed to be selected at once. If not, the first selected node is deselected when the second node is selected.
L Record Group: Specifies the name of the record group for the spanning tree.
A brief introduction to tree-related triggers (built-in):
L FUNCTION Get_tree_node_property (item_name VARCHAR2, node node, property number);
Function: Get Properties of tree node
Some of the property has the following:
Node_state:expanded_node (Extended node)
Collapsed_node (Shrink node)
Leaf_node (leaf node)--Note: cannot expand or shrink
Function: Add the data in the tree under the specified node
Note: Use more trouble.
L FUNCTION Find_tree_node (item_name varchar2,earch_string VARCHAR2, Search_type number,search_by number,search_r Oot node,start_point NODE);
Function: Locate the node that displays text or values that conform to search_string.
Parameters:
Search_type:find_next
Find_next_child
Search_by:node_label
Node_value
Search_root: The root node of the query, typically the Ftree.root_node
Start_point: The starting node of the lookup, typically the Ftree.root_node
L FUNCTION Add_tree_node (item_name varchar2,node ftree. NODE, Offset_type number,offset number,state number,label VARCHAR2, Icon Varchar2,value VARCHAR2);
Function: Adds a tree node.
Offset_type: Specifies the branch type of the node, Parent_offset and Sibling_offset
Offset: Specifies the location of the new node,
Parent_offset:1.. N
Last_child
Sibling_offset:next_node
Previous_node
State:expanded_node (Extended node)
Collapsed_node (Shrink node)
Leaf_node (leaf node)
L PROCEDURE Delete_tree_node (item_name varchar2,node NODE);
Function: Delete tree node
L FUNCTION get_tree_node_parent (item_name varchar2,node NODE);
Function: Gets the parent node of the specified node.
L FUNCTION get_tree_selection (item_name varchar2,selection number);
Function: Gets the node in the selected state.
L PROCEDURE set_tree_selection (item_name varchar2,node node, selection_type number);
Function: Specifies the selected state of a single node
Parameters:
selection_type:select_on
Select_off
Select_toggle
The trigger for the form's Run-time state:
L when-tree-node-activated: Triggered when the user clicks the node or presses the [ENTER] key when the nodes are selected.
L when-tree-node-expanded: Triggering when a node expands or shrinks
L when-tree-node-selected: Triggered when node is selected or deselected
Second, the way to build the tree
Tree controls are generally placed in a single control block (note: cannot be placed in a block of data), it is easy to place the tree on the canvas (CANVAS), and the tree's properties do not need to be set if it is not necessary.
There are several ways to build a tree:
L generate by setting a record group or data query property before running
L through the Add_tree_data trigger to achieve
L run state, through Add_tree_node and other triggers to achieve
L run state by adding or deleting data elements of a group of records to implement
Analysis:
First, direct operation of the tree
Description: Find_tree_node finds the specified node, Add_tree_node to add its subordinate nodes.
Disadvantages: Programming is more complex, not flexible operation, and error-prone.
Advantages: The process of adding nodes can be controlled to achieve some special requirements.
Example:
The cursor,emp_cur of the--dept_cur is the cursor of the employee.
The data format of the group of records used by the hierarchy tree:
+-car
|
--airplane
| -boeing
| -boeing
Initial state
Number of layers
Display text
Icon
Value
-1 (Shrink node)
1
' Car '
''
' Car '
0 (leaf node)
2
' Honda '
''
' Civic '
1 (Expand node)
1
' Airplane '
''
' Plane '
0
2
' Boeing '
''
' 747 '
0
2
' Boeing '
''
' 757 '
There are two different ways to generate a group of records.
1. Generate record group from query
Description: Use the tree query statement (connect By...prior...start with ...). Generates a group of records and sets the properties of the tree to be generated.
Advantages: Simple programming, convenient.
Disadvantage: Only applies if you can construct a tree-like query statement.
Conclusion: As far as possible, the parent-child structure should be placed on a table in database design, so it is most simple and practical to use the query to generate a record group to regenerate the tree. If this is not possible, a tree can also be generated by constructing the record group directly. If no special requirements, generally do not take the direct operation of the tree way.
Note: The authors typically place the tree-spanning program in the "program unit" of form builder, where needed, to refresh the tree in real time.
Reference: Developer 6.0 Pl/sql Library: NAVIGATE.PLL
III. Legacy Issues
Because developer simplifies the design of trees, some operations such as the transfer and copying of trees are not easy to implement. The subject still needs to be studied.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.