This discussion is archived
2 Replies Latest reply: Nov 26, 2012 6:16 AM by Mrucha RSS

populate_list from record group

723209 Newbie
Currently Being Moderated
I am using developer 10g forms with oracle database 10g.
I have below mentioned three tables.

1.     departments (deptid number(10) primary key, deptname varchar2(50)). This table is used to store departments
2.     sections (sectionid number(10) primary key, section_name varchar2(50),deptid number(10) foreign key to departments(deptid)). This table is used to store sections
3i.     employees(empid number(10) primary key,empname varchar2(50),deptid number(10) foreign key to departments(deptid), sectioned number(10) foreign key to sections(sectioned). this table is used to store employees record

I have created a form based on the employees table. I have done below mentioned.

1.     On the data block based on employees table, I have set the properties for deptid and sectioned properties to list item. I want to populate the data in the deptid from departments table and in the sectionid from the sections table which are existing in the deptid selected from the user at the run time.

2.     I have created two program units in the same form to create the record groups at the run time. Below mentioned is the code for these program units.

procedure create_departments_list
rg_name varchar2(40) := 'departments_list';
rg_id RecordGroup;
gc_id GroupColumn;
errcode NUMBER;
begin
rg_id := Find_Group(rg_name);
IF Id_Null(rg_id) then
rg_id := Create_Group(rg_name);
gc_id := Add_Group_Column(rg_id, 'deptname', CHAR_COLUMN, 50);
gc_id := Add_Group_Column(rg_id, 'deptid', CHAR_COLUMN, 40);
END IF;
errcode := Populate_Group_With_Query( rg_id,'select deptname,deptid from departments);
END;

procedure create_sections_list
rg_name varchar2(40) := 'sections_list';
rg_id RecordGroup;
gc_id GroupColumn;
errcode NUMBER;
begin
rg_id := Find_Group(rg_name);
IF Id_Null(rg_id) then
rg_id := Create_Group(rg_name);
gc_id := Add_Group_Column(rg_id, 'section_name', CHAR_COLUMN, 50);
gc_id := Add_Group_Column(rg_id, 'sectionid', CHAR_COLUMN, 40);
END IF;
errcode := Populate_Group_With_Query( rg_id,'select section_name,sectionid from sections where sectionid in (select sectionid from sections where deptid=’||:employees.deptid||’)’);
END;

3.     On the when-new-form-instance I have done the below mentioned:

create_departments_list;
populate_list('employees.deptid','departments_list');
create_sections_list;
populate_list('employees.sectionid','sections_list');

4.     When I run the form, the deparements are populating in the deptid list item but when I select department in from the deptid list item, no sections are populating in the sectionid list item. I want to populate the sections which are existing in the department selected from the user at run time. Can someone guide me what is the problem with the above mentioned code.

Thanks in advance.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points