Home » Developer & Programmer » Forms » Populate 2nd List while some value selected in First list
Populate 2nd List while some value selected in First list [message #259546] Wed, 15 August 2007 23:24 Go to next message
musman
Messages: 147
Registered: July 2007
Location: Lahore
Senior Member

there are three tables
---------
company
---------
c_id (pk)
c_name

---------
c_vehicle
---------
c_v_no (pk)
c_id (fk)

---------
c_entry
--------
sr_id (pk)
c_id (fk)
c_v_no (fk)

Now in [c_entry] table.
[c_id] and [c_v_no] both are list items.
I want that when i select some value in list [c_id]
then 2nd list [c_v_no] populates according to the value of
list [c_id]
-------------------------
How is it possible.Working in Forms 6i

[Updated on: Wed, 15 August 2007 23:24]

Report message to a moderator

Re: Populate 2nd List while some value selected in First list [message #259551 is a reply to message #259546] Wed, 15 August 2007 23:46 Go to previous messageGo to next message
azamkhan
Messages: 548
Registered: August 2005
Senior Member
Take both list item as non base table items where as the take the base table items C_ID and C_V_NO as display item with visible false.

Now On LIST-ITEM-CHANGED of C_ID populates the other list item C_V_NO and also move the values of C_ID & C_V_NO list item values into the coresponding base table items of your base table block.

Regards,
Azam Khan
Re: Populate 2nd List while some value selected in First list [message #259556 is a reply to message #259546] Thu, 16 August 2007 00:00 Go to previous messageGo to next message
hemavb
Messages: 103
Registered: May 2007
Location: Dubai , UAE
Senior Member
Musman,

Are you populating the both the lists dynamically?
If so make 2 different procedures. One to populate List 1 and the other for List 2.

If so, just call the procedure to populate List 2 in the WHEN-VALIDATE-ITEM trigger of the List 1.

Also add VALIDATE(item_scope) IN THE WHEN-LIST-CHANGED trigger of the List 1.

Need more help post back.

-Hemavb
Re: Populate 2nd List while some value selected in First list [message #259569 is a reply to message #259556] Thu, 16 August 2007 00:28 Go to previous messageGo to next message
musman
Messages: 147
Registered: July 2007
Location: Lahore
Senior Member

Yes,am populating both lists dynamically.
Ok let me try this first then will post back.
Re: Populate 2nd List while some value selected in First list [message #259962 is a reply to message #259556] Fri, 17 August 2007 00:38 Go to previous messageGo to next message
musman
Messages: 147
Registered: July 2007
Location: Lahore
Senior Member

Problem still exists..
First list populates well at from run time..
i use that same code on when_validate_item just changing condition in select query ..
On run time it did`nt give any error..
But 2nd list still not populating...(Empty 2nd list i found always at run time)

IF u can check i will paste code here

[Updated on: Fri, 17 August 2007 01:01]

Report message to a moderator

Re: Populate 2nd List while some value selected in First list [message #260274 is a reply to message #259962] Fri, 17 August 2007 23:29 Go to previous messageGo to next message
hemavb
Messages: 103
Registered: May 2007
Location: Dubai , UAE
Senior Member
check for the following:

1) is the query that you have written to populate the record group working in SQL?
2) is the length of the value column within the length limits of the list field?
3) check if the populate procedure for the 2nd list is being actually called.

if it is not too much paste the code here. the one that you are using in the when-new-form and when-validate-item.

-Hemavb
Re: Populate 2nd List while some value selected in First list [message #260448 is a reply to message #260274] Sun, 19 August 2007 23:47 Go to previous messageGo to next message
musman
Messages: 147
Registered: July 2007
Location: Lahore
Senior Member

hay i use each way as far as i concern but no avail.
thats code am using to populate 1st list on when_new_form_instance.
declare
	rg_name VARCHAR2(40) :='TYPEID';
	rg_id RecordGroup;
	gc_id GroupColumn;
	errcode NUMBER;
	
begin
	CLEAR_LIST('MAIN.SYS_ID');
	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,'DESCRIPTION',CHAR_COLUMN,60);	
		gc_id := Add_Group_Column(rg_id,'TYPE_ID',CHAR_COLUMN,3);
	
	end if;
	errcode := Populate_Group_With_Query(rg_id,
                      'select sym_code,company_code from companies order by sym_code');
	message('error code is'||errcode);
	POPULATE_LIST('MAIN.SYS_ID',RG_ID);
end;

----------------------------------------------------
and the code am using on when_validate_item on first list is
PROCEDURE list_control IS
BEGIN
  declare
	rg_name VARCHAR2(200) :='CID';
	rg_id RecordGroup;
	gc_id GroupColumn;
	errcode NUMBER; 
	checki NUMBER;
	
begin
	CLEAR_LIST('MAIN.C_NAME');
	rg_id := Find_Group( rg_name );   
	IF NOT Id_Null(rg_id) THEN     
		Delete_Group( rg_id );  
		END IF;
	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,'NAME',CHAR_COLUMN,100);	
		gc_id := Add_Group_Column(rg_id,'CID',CHAR_COLUMN,100);
	
	end if;
	errcode := Populate_Group_With_Query(rg_id,
                       'select company_name,company_code from companies
	where sym_code='||:SYS_ID);
	
	message('error code is'||sqlerrm);
	message('error code is'||errcode);

	POPULATE_LIST('MAIN.C_NAME',rg_name);
end;
END;


------------------------------------
queries working in sql fine.
2nd list populate is called and error come..
ORA-0000 successfull completion.
------------------------------------

[Updated on: Wed, 24 October 2007 20:34] by Moderator

Report message to a moderator

Re: Populate 2nd List while some value selected in First list [message #260449 is a reply to message #260274] Sun, 19 August 2007 23:48 Go to previous messageGo to next message
musman
Messages: 147
Registered: July 2007
Location: Lahore
Senior Member

if u can check this or u have some example that u have done like this do send me ..
will be thank full.
Re: Populate 2nd List while some value selected in First list [message #260633 is a reply to message #259546] Mon, 20 August 2007 09:29 Go to previous message
hemavb
Messages: 103
Registered: May 2007
Location: Dubai , UAE
Senior Member
Use the below code

For List 1.
DECLARE
   rg_name VARCHAR2(40) :='TYPEID';
   rg_id   RECORDGROUP;
   errcode NUMBER;
BEGIN
   CLEAR_LIST('MAIN.SYS_ID');
   rg_id := Find_Group(rg_name);
   IF Id_Null(rg_id) then
      rg_id := CREATE_GROUP_FROM_QUERY(rg_name ,
                   'select sym_code, company_code from companies order by sym_code');
   end if;
   errcode := POPULATE_GROUP(rg_name);
   MESSAGE('error code is'||errcode);
   errcode := POPULATE_LIST('MAIN.SYS_ID',RG_ID);
END;




For list 2
Before calling this procedure... check if the sys_id is not null.
PROCEDURE list_control IS
   rg_name VARCHAR2(200) :='CID';
   rg_id RecordGroup;
   errcode NUMBER; 	
begin
   CLEAR_LIST('MAIN.C_NAME');
   rg_id := Find_Group( rg_name );   
   IF Id_Null(rg_id) then
      rg_id := CREATE_GROUP_FROM_QUERY(rg_name ,
                   'select company_name,company_code from companieS where sym_code=  '''||:SYS_ID||'''');
   end if;
   errcode := POPULATE_GROUP(rg_name);
   MESSAGE('error code is'||errcode);
   errcode := POPULATE_LIST('MAIN.C_NAME',rg_name);
END;


checking your sql query closer... to the first query you are passing SYM_CODE and COMP_CODE.
DO they hold the same values?

If yes then no probs but if no, then there may be your problem. the first field that you enter in the query takes the list element label and the second field is the element value. So your list is passing the value of COMP_CODE into SYS_ID and not SYM_CODE. Also the 2nd list's query is also pikcing up the value of COMP_CODE.

if this is your problem you can modify the query of either of the list accordingly.

-Hemavb.

[Updated on: Wed, 24 October 2007 20:33] by Moderator

Report message to a moderator

Previous Topic: Calling a form from another form
Next Topic: get value
Goto Forum:
  


Current Time: Sun Dec 11 07:59:33 CST 2016

Total time taken to generate the page: 0.09790 seconds