Home » Developer & Programmer » Forms » Dynamic List Items (Oracle Forms 6i)
Dynamic List Items [message #504098] Thu, 21 April 2011 09:48 Go to next message
sivaora
Messages: 119
Registered: October 2009
Location: Hyderabad
Senior Member
Hi All,

I want to create two list items. one is for deptno and another is for empno in a single form.
Based on the selected deptno value from first list item i want to populate corresponding empno from second list item.
I tried with the fallowing code, it's work fine but the second list is not clears with the existing empno's.

Please help me on this...
Code for Deptno List item
declare
	cursor c is select deptno from dept;
	cnt number := 1;
begin
	clear_list('LI_DEPTNO');
	for i in c loop
		add_list_element('LI_DEPTNO',cnt,i.deptno,i.deptno);
		cnt := cnt + 1;
	end loop;
end;

Code for Empno list item in when_list_changed trigger for deptno list item
declare
cursor c is select empno from emp where deptno = :LI_DEPTNO;
cnt number := 1;
begin
it_id := Find_Item('LI_EMPNO');
clear_list(it_id);
for i in c loop
add_list_element('LI_EMPNO',cnt,i.empno,i.empno);
cnt := cnt + 1;
end loop;
end;
Re: Dynamic List Items [message #504102 is a reply to message #504098] Thu, 21 April 2011 09:58 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
I'd stop that. Dynamic list items never work properly because:
a) You can't clear a value from a list item if it's in use in any current record in the block.
b) If you try to query a record and the value in the db column that corresponds to the list item isn't recognized by the list item, the form will just not return the record and won't give an idication that it's done so.

Just use text items with LOV's, it'll make your life a whole lot simpler.
Re: Dynamic List Items [message #504381 is a reply to message #504102] Sun, 24 April 2011 07:48 Go to previous messageGo to next message
mehediu
Messages: 46
Registered: February 2010
Location: Dhaka
Member

Hi,

you can use the following procedure and use the procedure
as i write there. i hope this will help you.

Thanks.

V_STR := 'SELECT U.USER_NAME,TO_CHAR(ID) FROM emp 
		WHERE deptno  = '||V_TEAMID||'
		order by 1';
		
		POP_LIST ('BLK_SEARCH.TXTTEAM',V_STR); ---- BLK_SEARCH.TXTTEAM is list item.



PROCEDURE POP_LIST (p_listitem varchar2,p_string varchar2) IS
		group_id RecordGroup;		
		list_s Item := Find_Item(p_listitem);
		status NUMBER;
		rg_name varchar2(40) := 'recgroup';
BEGIN
-------------------------
		clear_list(list_s);
		group_id := Find_Group(rg_name);
		IF NOT id_null(group_id) then
		    Delete_Group(group_id);
		End if;
		group_id := Create_Group_From_Query(rg_name,p_string);
		
	
		status := Populate_Group(rg_name);
		Populate_List(list_s, group_id);

-------------------------
		
END;
Re: Dynamic List Items [message #504390 is a reply to message #504381] Sun, 24 April 2011 13:04 Go to previous message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
sivaora's main problem is that clear_list isn't working. Your code isn't going to fix that.
Previous Topic: Applying Different Background Colour
Next Topic: Delete Option not Working
Goto Forum:
  


Current Time: Tue Sep 17 16:18:57 CDT 2024