الانتقال إلى المحتوى
View in the app

A better way to browse. Learn more.

مجموعة مستخدمي أوراكل العربية

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

استفسار عن مثال بسيط لتوضيح الشجرة

Featured Replies

بتاريخ:

السلام عليكم يا اخواني
انا مشترك جديد في المنتدى الرائع دة ولسة خريج بس عايز طلب صغير انا عملت شجرة بس مش مرتبة عايز مثال بسيط يوضح كيفية العرض ولاضافة في الشجرة انا شفت امثلة كتيرة ما فهمت منها اي شي رجاء حدي يرسلي مثال
اشكركم جميعا
وجزاكم الله خير

بتاريخ:

السلام عليكم ورحمة الله وبركاته

- إنشاء MODUEL جديد وتغيير اسمه إلي ATREE

2 - إنشاء Canvases جديد وتغيير اسمها إلي CANV

3 - إنشاء Data blocks جديد وذلك من خلال اختيار Build a new data block manually
ومن ثم نقوم بتسميته TREE_BL

4 - إنشاء Items جديد داخل الـ TREE_BL باسم HTREE ومن خلال الـ Property Palette نقوم بتغيير
1 - الـ Item Type : من Text Item إلي Hierarchical Tree
2 - الـ Canvas : من Null إلي CANV
3 - نقوم بنسخ ولصق الكود التالي في الـ Data Query


select  1 , level , ename , null , to_char(empno)
from emp start with mgr is null
connect by prior empno = mgr



ملاحظة : عند كتابة الكود السابق في بيئة SQL*Plus تكون المخرجات كما يلي

5 - إنشاء الـ Triggers التالي علي مستوي الـ MODUEL المسمي باسم ATREE

WHEN-NEW-FORM-INSTANCE

declare
htree_item	item ;
begin htree_item := find_item('tree_bl.htree') ;	
ftree.populate_tree(htree_item) ;
end ; OR ftree.populate_tree('tree_bl.htree') ;



ملاحظات :
populate_tree(item_id in forms4c.item) OR populate_tree(item_name in varchar2)

FIND_ITEM Built-in
Description
Searches the list of items in a given block and returns an item ID when it finds a valid item with the given name. You must define an appropriately typed variable to accept the return value. Define the variable with a type of Item.

Syntax
FUNCTION FIND_ITEM(block.item_name VARCHAR2);
Built-in Type unrestricted function
Returns Item
Enter Query Mode yes

Parameters
block_name.item_name : Specifies the fully qualified item name. The data type of the name is VARCHAR2.

FIND_ITEM Examples

/*** Built-in: FIND_ITEM
** Example: Find an item's Id before setting several
** of its properties.
*/ PROCEDURE Hide_an_Item( item_name VARCHAR2, hide_it BOOLEAN) IS it_id Item;
BEGIN
it_id := Find_Item(item_name);
IF Id_Null(it_id)
THEN Message('No such item: '||item_name);
RAISE Form_Trigger_Failure;
ELSE IF hide_it THEN
Set_Item_Property(it_id,VISIBLE,PROPERTY_FALSE);
ELSE
Set_Item_Property(it_id,VISIBLE,PROPERTY_TRUE); Set_Item_Property(it_id,ENABLED,PROPERTY_TRUE); Set_Item_Property(it_id,NAVIGABLE,PROPERTY_TRUE);
END IF;
END IF;
END;





وعند عمل Run Form يكون شكل الشجرة كما يلي ( شاشة ATREE )



وعند تغيير القيمة 1 إلي رقم –1 في الكود الذي تم نسخه في الـ Data Query كما يلي

select  -1 , level , ename , null , to_char(empno)
from emp start with mgr is null
connect by prior empno = mgr



وعند عمل Run Form يكون شكل الشجرة كما يلي ( شاشة 2ATREE )
وعند الضغط علي إشارة الـ + يتم إظهار أسماء الموظفين


وعند تغيير الكود الذي تم نسخه في الـ Data Query كما يلي

select  1 , level , to_char(empno) , null , ename
from emp start with mgr is null
connect by prior empno = mgr



وعند عمل Run Form يكون شكل الشجرة كما يلي ( شاشة 3ATREE )


وعند تغيير الكود الذي تم نسخه في الـ Data Query كما يلي


select  1 , level , ename||' /  '||to_char(empno) , null , ename
from emp start with mgr is null
connect by prior empno = mgr



وعند عمل Run Form يكون شكل الشجرة كما يلي ( شاشة 4ATREE )

وعند تغيير الكود الذي تم نسخه في الـ Data Query كما يلي

select  1 , level , ename , null , null
from emp start with mgr is null
connect by prior empno = mgr OR select  1 , level , ename , to_char(mgr) , to_char(empno)  
from emp start with mgr is null
connect by prior empno = mgr




وعند عمل Run Form يكون شكل الشجرة كما يلي ( شاشة 5ATREE )



وعند تغيير الكود الذي تم نسخه في الـ Data Query كما يلي

select  1 , 1 , 'departments' , null , null
from dual union all
select  1 , 2 , dname , null , to_char(deptno)
from dept union all
select  1 , 3 , ename , null , job
from emp




وعند عمل Run Form يكون شكل الشجرة كما يلي ( شاشة 6ATREE )


لو تم إنشاء view في الـ Data كما يلي

create or replace  view  department_emp  as select  1 state , 1 levl , 'DEPARTMENTS' displ_val , null icn , null val , '1' sort_value
from dual union all
select  1 , 2 , dname , null , to_char(deptno) , to_char(deptno)
from dept union all
select  1 , 3 , ename , null , to_char(empno) , to_char(deptno)
from emp ;



وعند تغيير الكود الذي تم نسخه في الـ Data Query كما يلي

select  state , levl , displ_val||' /  '||val , sort_value , val
from department_emp order by sort_value ;



وعند عمل Run Form يكون شكل الشجرة كما يلي ( شاشة 7ATREE )

لعرض بيانات الموظف عند الضغط علي اسم الموظف
1 - إنشاء New Data Block من خلال استخدام Use the Data Block Wizard للجدول EMP
2 - إنشاء الـ Triggers التالي علي مستوي الـ TREE_BL

WHEN-TREE-NODE-SELECTED
declare
rank  number :=0 ;
begin rank := ftree.get_tree_node_property('tree_bl.htree', :system.trigger_node , ftree.node_depth) ;
if rank = 3 then
go_block('emp') ;
set_block_property('emp' , default_where , 'empno='||ftree.get_tree_node_property('tree_bl.htree', :system.trigger_node , ftree.node_value)) ;
execute_query ;
else
go_block('emp') ;
clear_block ;
end if ;
end ; OR declare
v_htree       item ;
node_value    number ;
begin message('التسلسل الشجري'||'  '||:system.trigger_node , no_acknowledge) ;
v_htree := find_Item('tree_bl.htree') ;
node_value := ftree.get_tree_node_property(v_htree , :system.trigger_node , ftree.node_value) ;
if node_value > 40 then
go_block('emp') ;
set_block_property('emp', default_where , 'empno ='|| node_value ) ;
go_block('emp') ;
execute_query ;
else
go_block('emp') ;
clear_block ;
end if ;
end ;



وعند عمل Run Form ومن ثم اختيار الموظف SCOTT يكون شكل الشاشة كما يلي ( شاشة 8ATREE )

عند حذف الكود الذي تم نسخه في الـ Data Query ونسخ الكود التالي في الـ Triggers علي مستوي الـ MODUEL المسمي باسم ATREE9

WHEN-NEW-FORM-INSTANCE 

Declare
cursor  dept_cur   is  select  deptno , dname     from   dept ;
cursor  emp_cur (N number)  is    select  empno , ename      from emp where deptno=N ;
htree     item ;
parent_node  varchar2(1000) ;
child_node     varchar2(1000) ;
begin htree :=find_item('tree_bl.htree') ;
For dept_r in dept_cur loop 
parent_node :=ftree.add_tree_node(htree , ftree.root_node , ftree.parent_offset , ftree.last_child , 
ftree.expanded_node , dept_r.deptno||' /  '||dept_r.dname , 'insrec' , dept_r.deptno ) ;
Htree :=Find_item('tree_bl.htree') ;
For emp_r in emp_cur(dept_r.deptno) loop
child_node :=ftree.add_tree_node(htree , parent_node , ftree.parent_offset , ftree.last_child , 
ftree.expanded_node , emp_r.empno||' /  '||emp_r.ename , 'insrec' , emp_r.empno ) ;
end loop ;  end loop ;   end ;



ونسخ الكود التالي في الـ Triggers علي مستوي الـ TREE_BL

WHEN-TREE-NODE-SELECTED
declare
v_htree       item ;
node_value    number ;
begin message('التسلسل الهرمي'||'  '||:system.trigger_node , no_acknowledge) ;
v_htree := find_Item('tree_bl.htree') ;
node_value := ftree.get_tree_node_property(v_htree , :system.trigger_node , ftree.node_value) ;
if node_value > 40 then
go_block('emp') ;
set_block_property('emp', default_where , 'empno ='|| node_value ) ;
go_block('emp') ;
execute_query ;
else
go_block('emp') ;
clear_block ;
end if ;    end ;



وعند عمل Run Form ومن ثم اختيار الموظف SCOTT يكون شكل الشاشة كما يلي ( شاشة 9ATREE )


جزاكم الله كل خير

بتاريخ:

ملاحظات : 
Ftree.add_tree_node(item_name in varchar2 , node in node , offset_type in number , offset in number , state in number , label in varchar2 , icon in varchar2 , value in varchar2)  Return PLS_INTEGER ;
Ftree.add_tree_node(item_id in forms4c.item , node in node , offset_type in number , offset in number , state in number , label in varchar2 , icon in varchar2 , value in varchar2)  Return PLS_INTEGER ;
ADD_TREE_NODE Built-in
Description : Adds a data element to a hierarchical tree item.
Syntax :
FUNCTION ADD_TREE_NODE (item_name VARCHAR2, node FTREE.NODE, offset_type NUMBER, offset NUMBER, state NUMBER, label VARCHAR2, icon VARCHAR2, value VARCHAR2); 
FUNCTION ADD_TREE_NODE (item_id ITEM, node FTREE.NODE, offset_type NUMBER, offset NUMBER, state NUMBER, label VARCHAR2, icon VARCHAR2, value VARCHAR2); 
Built-in Type : unrestricted procedure        Returns : NODE      Enter Query Mode : no 
Parameters
item_name : Specifies the name of the object created at design time. The data type of the name is 
VARCHAR2 string.
Item_id : Specifies the unique ID that Oracle Forms assigns to the item when created. Use the 
FIND_ITEM built-in to return the ID to an appropriately typed variable. The data type of the ID is Item.
Node : Specifies a valid node. There is a special value FTREE.ROOT_NODE which can be used to 
define the root of the tree.
offset_type : Specifies the type of offset for the node. Possible values are: 
PARENT_OFFSET   ,   SIBLING_OFFSET
Offset : Indicates the position of the new node. 
If offset_type is PARENT_OFFSET, then offset can be either 1-n or LAST_CHILD. 
If offset_type is SIBLING_OFFSET, then offset can be either NEXT_NODE or PREVIOUS_NODE.
State : Specifies the state of the node. Possible vaues are: 
COLLAPSED_NODE  ,  EXPANDED_NODE  ,  LEAF_NODE
label : The displayed text for the node.
Icon : The filename for the node’s icon.
Value : Specifies the VARCHAR2 value of the node. 
ADD_TREE_NODE Examples
/*Built-in: ADD_TREE_NODE */ 
/*This code copies a value from a Form item and adds it to the tree as a top level node. The value is set to be the same as the label.*/
DECLARE 
htree ITEM;
top_node FTREE.NODE;
new_node FTREE.NODE;
item_value VARCHAR2(30);
BEGIN
/*Find the tree itself.*/
htree := Find_Item('tree_block.htree3');
/*Copy the item value to a local variable. */ 
item_value := :wizard_block.new_node_data;   
/*Add an expanded top level node to the tree  with no icon.*/  
new_node := Ftree.Add_Tree_Node(htree, Ftree.ROOT_NODE, Ftree.PARENT_OFFSET, Ftree.LAST_CHILD, Ftree.EXPANDED_NODE,  item_value,  NULL, item_value);  
END;



لو تم استبدال الـ view السابقة في الـ Data كما يلي

create or replace  view  department_emp  as select  1 state , 1 levl , 'DEPARTMENTS' displ_val , 'insrec' icn , null  val , '1' sort_value
from dual union all
select  1 , 2 , dname , 'insrec' , to_char(deptno) , to_char(deptno)
from dept union all
select  1 , 3 , ename , 'insrec' , to_char(empno) , to_char(deptno)
from emp ;



وعند تغيير الكود الذي تم نسخه في الـ Data Query كما يلي

select  state , levl , displ_val||' /  '||val , icn , val
from department_emp order by sort_value



وعند عمل Run Form ومن ثم اختيار الموظف SCOTT يكون شكل الشاشة كما يلي ( شاشة 10ATREE )

عند حذف الكود الذي تم نسخه في الـ Data Query ونسخ الكود التالي في الـ Triggers علي مستوي الـ MODUEL المسمي باسم ATREE11

WHEN-NEW-FORM-INSTANCE

ftree.set_tree_property('tree_bl.htree', ftree.query_text ,
'select  1 , level , ename , ''insrec'' , to_char(empno)
from emp start with mgr is null
connect by prior empno = mgr') ;
ftree.populate_tree('tree_bl.htree') ;



ونسخ الكود التالي في الـ Triggers علي مستوي الـ TREE_BL

WHEN-TREE-NODE-SELECTED

declare
v_htree       item ;
node_value    number ;
begin message('التسلسل الشجري'||'  '||:system.trigger_node , no_acknowledge) ;
v_htree := find_Item('tree_bl.htree') ;
node_value := ftree.get_tree_node_property(v_htree , :system.trigger_node , ftree.node_value) ;
if node_value > 40 then
go_block('emp') ;
set_block_property('emp', default_where , 'empno ='|| node_value ) ;
execute_query ;
else
go_block('emp') ;
clear_block ;
end if ;   
end ;



وعند عمل Run Form ومن ثم اختيار الموظف SCOTT يكون شكل الشاشة كما يلي ( شاشة 11ATREE )


آو نسخ الكود التالي في الـ Triggers علي مستوي الـ MODUEL المسمي باسم ATREE12

WHEN-NEW-FORM-INSTANCE

ftree.set_tree_property('tree_bl.htree' , ftree.query_text , 
'select  state , levl , displ_val||'' /  ''||val , icn , val
from department_emp order by sort_value') ;
ftree.populate_tree('tree_bl.htree');



وعند عمل Run Form ومن ثم اختيار الموظف SCOTT يكون شكل الشاشة كما يلي ( شاشة 12ATREE )

في الشاشة 12ATREE لو تم إنشاء Data blocks جديد وذلك من خلال اختيار Build a new data block manually
ومن ثم نقوم بتسميته PUSH_BL ومن ثم نقوم بإنشاء PUSH_BUTTON بداخله ونقوم بإنشاء الـ Triggers التالية

WHEN-BUTTON-PRESSED

ftree.set_tree_property('tree_bl.htree', ftree.query_text ,
'select  1 , level , ename , ''insrec'' , to_char(empno)
from emp start with mgr is null
connect by prior empno = mgr') ;

ftree.populate_tree('tree_bl.htree') ;



WHEN-MOUSE-DOUBLECLICK

ftree.set_tree_property('tree_bl.htree' , ftree.query_text , 
'select  state , levl , displ_val||'' /  ''||val , icn , val
from department_emp order by sort_value') ;
ftree.populate_tree('tree_bl.htree');



آو يمكن إنشاء PUSH_BUTTON عدد 2 واحد للإدارات والآخر للمدراء

وعند عمل Run Form يكون شكل الشاشة كما يلي ( شاشة 13ATREE )

لو تم إنشاء الـ Triggers التالي علي مستوي الـ MODUEL المسمي باسم ATREE14

WHEN-NEW-FORM-INSTANCE

declare
rg_num  number ;
htree_item	item ;
begin rg_num := populate_group('depart') ;
htree_item := find_item('tree_bl.htree') ;	
ftree.populate_tree(htree_item) ;
end ;



وحذف الكود الذي تم نسخه في الـ Data Query

وإنشاء Record Groups باسم DEPART ونسخ الكود التالي بداخله

select  state , levl , displ_val||' /  '||val , icn , val
from department_emp order by sort_value




ومن خلال الـ Property Palette للـ HTREE نقوم بتغيير الخاصية
Record Group : من Null إلي DEPART
ومن خلال الـ Property Palette للـ TREE_BL نقوم بتغيير الخاصية
Query All Records : من NO إلي Yes

وننسخ الكود التالي في الـ Triggers علي مستوي الـ TREE_BL

WHEN-TREE-NODE-SELECTED
declare
v_htree       item ;
node_value    number ;
begin message('التسلسل الهرمي'||'  '||:system.trigger_node , no_acknowledge) ;
v_htree := find_Item('tree_bl.htree') ;
node_value := ftree.get_tree_node_property(v_htree , :system.trigger_node , ftree.node_value) ;
if node_value > 40 then
go_block('emp') ;
set_block_property('emp', default_where , 'empno ='|| node_value ) ;
execute_query ;
else
go_block('emp') ;
clear_block ;
end if ;   
end ;




وعند عمل Run Form ومن ثم اختيار الموظف SCOTT يكون شكل الشاشة كما يلي ( شاشة 14ATREE

POPULATE_GROUP Built-in Description
Executes the query associated with the given record group and returns a number indicating success or failure of the query. Upon a successful query, POPULATE_GROUP returns a 0 (zero). An unsuccessful query generates an ORACLE error number that corresponds to the particular SELECT statement failure. The rows that are retrieved as a result of a successful query replace any rows that exist in the group. 
POPULATE_GROUP is necessary to populate a record group before using the SET_TREE_PROPERTY(RECORD_GROUP) option.
Note: Be aware that the POPULATE_GROUP array fetches 100 records at a time. To improve network performance, you may want to restrict queries, thus limiting network traffic.
Syntax
FUNCTION POPULATE_GROUP(recordgroup_id RecordGroup); 
FUNCTION POPULATE_GROUP(recordgroup_name VARCHAR2); 
Built-in Type unrestricted function 
Returns NUMBER 
Enter Query Mode yes
Parameters
recordgroup_id : The unique ID that Oracle Forms assigns when it creates the group. The data type 
of the ID is RecordGroup.  
recordgroup_name : The name you gave to the record group when creating it. The data type of the 
name is VARCHAR2. On Failure : When the Populate_Group Built-in fails because the record group does not exist, a 
NULL value is returned.
POPULATE_GROUP Restrictions
Valid only for record groups: 
that were created at design time with a query 
that were created by a call to the CREATE_GROUP_FROM_QUERY built-in that have been previously populated with the POPULATE_GROUP_WITH_QUERY built-in (which associates a query with the record group)
POPULATE_GROUP Example
Built-in : POPULATE_GROUP 
Example : See GET_GROUP_ROW_COUNT and CREATE_GROUP_FROM_QUERY


لو تم استبدال الـ view السابقة في الـ Data كما يلي

create or replace  view  department_emp  as select  1 state , 1 levl , 'DEPARTMENTS' displ_val , 'insrec' icn , 1  val  , 1  sort_value
from dual union all
select  1 , 2 , dname , 'insrec' , 2 , deptno
from dept union all
select  1 , level+2 ,  ename , 'insrec' , empno ,deptno
from emp start with mgr is null
connect by prior empno = mgr ;




وعند تغيير الكود الذي تم نسخه في الـ Data Query كما يلي


select  state , levl , displ_val||' /  '||val , icn , val
from department_emp order by sort_value , levl



وعند عمل Run Form ومن ثم اختيار الموظف SCOTT يكون شكل الشاشة كما يلي ( شاشة 15(ATREE

عند استخدام خاصية البحث في الجهاز للبحث عن الملفات التي تحمل اسم insrec تم إيجاد الملف التالي
insrec oracle/forms/icons
وعند تحديد الملف والضغط علي الزر الأيمن للماوس واختيار الخيار Open Containing Folder تظهر الشاشة التالية

وعند الضغط علي السهم الموجود علي الـ Address يظهر امتداد الملف كما يلي

لو تم استبدال الـ view السابقة في الـ Data كما يلي

create or replace  view  department_emp  as select  1 state , 1 levl , 'DEPARTMENTS' displ_val , 'splash' icn , 1  val  , 1  sort_value
from dual union all
select  1 , 2 , dname , 'prvrec' , 2 , deptno
from dept union all
select  1 , level+2 ,  ename , 'prvblk' , empno , deptno
from emp start with mgr is null
connect by prior empno = mgr ;



وعند عمل Run Form ( للشاشة السابقة ) ومن ثم اختيار الموظف SCOTT يكون شكل الشاشة كما يلي ( شاشة 15(ATREE

لو تم نسخ الـكود التالي علي مستوي الـ MODUEL المسمي باسم ATREE16

WHEN-NEW-FORM-INSTANCE

ftree.set_tree_property('tree_bl.htree', ftree.query_text ,
'select 1 , level , lpad(ename,length(ename)+LEVEL*2 , '' '' )||'' /  ''||empno , ''prvrec'' , empno
from emp where ename<>''BLAKE''
start with ename=''KING''
connect by prior empno=mgr') ;
ftree.populate_tree('tree_bl.htree') ;



وعند عمل Run Form ومن ثم اختيار الموظف SCOTT يكون شكل الشاشة كما يلي ( شاشة 16(ATREE


جزاكم الله كل خير

بتاريخ:
  • كاتب الموضوع

شكرا يا اخ jamal_rrkk وجاري التجربة
جزاك الله الف خير واتمنالك التوفيق يا رب

  • بعد 1 شهر...
بتاريخ:

يا جمال

اريد شرح بالعربي ل hierchical tree ضروري جدا

بتاريخ:

وياليت بالصور وشكرا

  • بعد 1 سنة...
بتاريخ:

Thank you very much

بتاريخ:

شكرا يا اخ jamal_rrkk

  • بعد 4 شهور...
بتاريخ:

الله يجازيك والف شكر الك، تمنياتي بالتوفيق والنجاح الدائمين.

  • بعد 10 شهور...
بتاريخ:

الاخ الكريم شكرا علي هذو المعلومة الجيدة والمفيدة فقط نرجو منك ارفاق مثال لو سمحت ونسال الله ان يجعل هذا العمل في ميزان حسناتك

بتاريخ:

السلام عليكم ورحمة الله وبركاته

اخي الكريم

الملف المرفق يحتوي على الشاشات التي تم شرحها في الأعلى

ولقد تم تصميمها بنسخة 10g

جزاك الله كل خير

Hierarchical_Tree.rar

بتاريخ:

السلام عليكم ورحمة الله وبركاته

الملف المرفق يحتوي على الشرح حيث تم حذف الصور منه ليتم تحميله

جزاك الله كل خير

tree.rar

انضم إلى المناقشة

يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.

زائر
أضف رد على هذا الموضوع...

برجاء الإنتباه

بإستخدامك للموقع فأنت تتعهد بالموافقة على هذه البنود: سياسة الخصوصية

Account

Navigation

البحث

إعداد إشعارات المتصفح الفورية

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.