在plsql中构建组 - 子组下拉列表

时间:2017-05-29 08:43:00

标签: oracle plsql oracleforms

我有一个表格,其中包含 ID GROUP_NAME PARENT_GROUP_ID 。我正在尝试创建两个下拉列表:首先将所有具有 parent_group_id 的组名称作为null,在选择第一个ddl(或仅选择默认值)后,第二个ddl中的值应该都具有 PARENT_GROUP_ID 列等于第一个选定组的ID。到目前为止,我已经创建了包含2个poplists的数据块,并且在'when-new-form-instance'中我用

填充了第一个ddl
DECLARE
 rg_groups RecordGroup; 
 rg_group_name VARCHAR2(5) := 'GNAME'; 
 plist_ID Item := Find_Item(':GROUPS.GROUP_NAME'); 
 nDummy NUMBER;
BEGIN 
  rg_groups := Find_Group(rg_group_name); 
 -- Delete any existing Group first 
  IF NOT Id_Null(rg_groups) THEN 
    Delete_Group(rg_groups); 
  END IF;
 -- Now create a Record Group using a SQL query 
  -- Your Query must have a Label and a Value (two Columns) 
  -- and the data types must match your item type 
  rg_groups := Create_Group_From_Query(rg_group_name,'SELECT group_name, 
  to_char(ID) FROM GROUPS WHERE PARENT_GROUP_ID IS NULL'); 
  -- Clear the existing List 
  Clear_List(plist_ID); 
  -- Populate the Record Group 
  nDummy := Populate_Group(rg_groups); 
  -- Populate the List Item 
  Populate_List(':GROUPS.GROUP_NAME',rg_groups);
END;

在第一个poplist项的'post-change'触发器上,填充第二个ddl:

DECLARE
 rg_groups RecordGroup; 
 rg_group_name VARCHAR2(5) := 'GPARENT_NAME'; 
 plist_ID Item := Find_Item(':GROUPS.PARENT_GROUP_ID'); 
 nDummy NUMBER;
BEGIN 
  rg_groups := Find_Group(rg_group_name); 
  -- Delete any existing Group first 
  IF NOT Id_Null(rg_groups) THEN 
    Delete_Group(rg_groups); 
  END IF;
   -- Now create a Record Group using a SQL query 
   -- Your Query must have a Label and a Value (two Columns) 
   -- and the data types must match your item type 
   rg_groups := Create_Group_From_Query(rg_group_name,'SELECT group_name, to_char(ID) FROM GROUPS WHERE PARENT_GROUP_ID = ' || :GROUPS.ID); 
   -- Clear the existing List 
   Clear_List(plist_ID); 
 -- Populate the Record Group 
 nDummy := Populate_Group(rg_groups); 
 -- Populate the List Item 
 Populate_List(':GROUPS.PARENT_GROUP_ID',rg_groups);
END;

但是我觉得部分WHERE PARENT_GROUP_ID = ' || :GROUPS.ID是错的,因为我甚至没有填写ID,我需要从之前的ddl中提取它,这就是我被困住的地方,我不太了解这在oracle表单中是如何工作的。我希望我能得到一些易于理解的建议,谢谢!

1 个答案:

答案 0 :(得分:1)

弹出列表通常有两列 - 显示标签和值存储到项目。

您的第一个弹出列表位于GROUPS.GROUP_NAME项目上,显示组名称并存储组ID。这意味着当用户选择一个组时,其ID将存储到GROUPS.GROUP_NAME,并且您的第二个弹出列表将填入错误的值。

只需从GROUPS.GROUP_NAME删除您的第一个弹出列表,然后在GROUPS.ID项目上创建。

BTW:当你按名字引用一个项目时,不要使用冒号。 Find_Item(':GROUPS.GROUP_NAME')不好,Find_Item('GROUPS.GROUP_NAME')是对的。