Home » Developer & Programmer » Forms » Storing data into the combo box
Storing data into the combo box [message #260833] Tue, 21 August 2007 01:39 Go to next message
james_aron
Messages: 32
Registered: July 2007
Location: chennai
Member
hi all,
I am working in oracle forms 6i. My problem is, I want to store data into the combo box from the back-end(sql database server). My combo box is none database item please help me of how to store data into combo box from database.

I created trigger like below but its not working.

WHEN-NEW-ITEM-INSTANCE
------------------------
declare
begin
loop
select prod_name into :control_main.combo from stock;
end loop;
end;

hope u guys will help me!


regards,
jame

[Updated on: Tue, 21 August 2007 01:42]

Report message to a moderator

Re: Storing data into the combo box [message #260836 is a reply to message #260833] Tue, 21 August 2007 01:46 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
A combo box is based on a 'record_group'. I strongly suggest that you build the 'record_group' in the Forms Builder at build time and not worry about making it a dynamic record_group. Then associated it with an LOV and associate it with an item.

See how that works for you and get back to us.

David
Re: Storing data into the combo box [message #260841 is a reply to message #260833] Tue, 21 August 2007 01:53 Go to previous messageGo to next message
DRASTANT
Messages: 21
Registered: July 2007
Location: KENYA
Junior Member
Helllooo james how r u????

Here is solution for your problem

first u decide how u want to store data is it static or query based,

1. if it is static just go to property palate and add elements in list

2. if it is based on a query u need to create a record group based on query u need to fill the combobox and then u need to populate this combo box using this record group u can use
POPULATE_LIST built in for doing this on any trigger level


hope this should solve your problem

Drastant Mehta
Nairobi
Re: Storing data into the combo box [message #260849 is a reply to message #260841] Tue, 21 August 2007 02:09 Go to previous messageGo to next message
james_aron
Messages: 32
Registered: July 2007
Location: chennai
Member
Hi all,
I am Fine Drastant Mehta, I have created lov and i have written code for lov in when-new-item-instance trigger but this is not populating inside the combo-box.

And how we have to use POPULATE_LIST and what is the return type

thanks

regards,
jame

[Updated on: Tue, 21 August 2007 02:21]

Report message to a moderator

Re: Storing data into the combo box [message #260885 is a reply to message #260849] Tue, 21 August 2007 03:25 Go to previous messageGo to next message
musman
Messages: 147
Registered: July 2007
Location: Lahore
Senior Member

you have to create arg list and columns ..do try it ur self.
--------------------------------------------------------
hay i use this code on non database item to populate list.
Use this on Form level WHEN_NEW_FORM_INSTANCE..
it will work..
-------------------------------------------------------
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;


Use combo-box list ...

Upd-mod: Code line too long.

[Updated on: Thu, 23 August 2007 20:28] by Moderator

Report message to a moderator

Re: Storing data into the combo box [message #260955 is a reply to message #260833] Tue, 21 August 2007 05:59 Go to previous messageGo to next message
hemavb
Messages: 103
Registered: May 2007
Location: Dubai , UAE
Senior Member
Same code modified it a little...

Musman, no hard feelings.

declare
	rg_name VARCHAR2(40) :='TYPEID';
	rg_id RecordGroup;
	errcode NUMBER;
	
begin
	CLEAR_LIST('MAIN.SYS_ID');  -- MAIN.SYS_ID is the List Item
	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_id);
	message('error code is'||errcode);
	POPULATE_LIST('MAIN.SYS_ID',RG_ID);
end;

[Updated on: Thu, 23 August 2007 20:29] by Moderator

Report message to a moderator

Re: Storing data into the combo box [message #260961 is a reply to message #260849] Tue, 21 August 2007 06:34 Go to previous messageGo to next message
DRASTANT
Messages: 21
Registered: July 2007
Location: KENYA
Junior Member
James just read this

Create a Record Group not lov and then populate it on using this code
create a rg_dept as record group
department as combo box item
i m using it with forms 10g
try it out


DECLARE
STATUS NUMBER;
Problem EXCEPTION;
BEGIN
STATUS:=POPULATE_GROUP('rg_dept');
IF STATUS <> 0 THEN
RAISE problem;
ELSE
POPULATE_LIST('DEPARTMENT', 'rg_dept');
END IF;
EXCEPTION
WHEN problem THEN
message('We have a problem to query the PRODUCT table.');

END;
Re: Storing data into the combo box [message #260976 is a reply to message #260955] Tue, 21 August 2007 07:13 Go to previous messageGo to next message
musman
Messages: 147
Registered: July 2007
Location: Lahore
Senior Member

its ok
@hemavb

[Updated on: Tue, 21 August 2007 07:14]

Report message to a moderator

Re: Storing data into the combo box [message #261107 is a reply to message #260976] Tue, 21 August 2007 19:15 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Why, oh why, do you people insist on making work for yourselves?? Just create the 'record_group' and 'lov' in the Forms Builder and then USE it. There is no need for all this extra code. Forms WILL DO IT FOR YOU!!

David
Re: Storing data into the combo box [message #261188 is a reply to message #260833] Wed, 22 August 2007 02:07 Go to previous messageGo to next message
hemavb
Messages: 103
Registered: May 2007
Location: Dubai , UAE
Senior Member
I agree David, but there are cases when a client is adamant on using a drop down list where an LOV would do wonders.
It takes time for them to the "popped - up" list as a client of mine calls it. But soon they are more happy with "pressing F9" rather than the drop-down list. Till then we have to work extra.

-Hemavb
Re: Storing data into the combo box [message #261207 is a reply to message #261188] Wed, 22 August 2007 02:56 Go to previous messageGo to next message
sispk6
Messages: 164
Registered: November 2006
Location: pakistan
Senior Member
DAVID
FORMS 9I SAYS = L.O.V IS OBSELETE
Re: Storing data into the combo box [message #261219 is a reply to message #260833] Wed, 22 August 2007 03:10 Go to previous messageGo to next message
hemavb
Messages: 103
Registered: May 2007
Location: Dubai , UAE
Senior Member
LOV is a much better form of selection tool than drop down lists.
The Users can resize an LOV, they can get more info in the form of additional columns, search scope is widened.

As far as i go i will at any time prefer to give my clients LOVs be it 6, 6i, 9i or 10g. Even when i give them a drop down field i still provide an LOV for the same selection. I know that clients will use it more than the drop down, once they come to know that the filtering options available in LOV are much much better than a drop List.

-Hemavb
Re: Storing data into the combo box [message #261343 is a reply to message #261219] Wed, 22 August 2007 06:22 Go to previous messageGo to next message
james_aron
Messages: 32
Registered: July 2007
Location: chennai
Member
hi all,
Thank you very much for ur replies.....but still i had problem.

My record group name(not lov) is RG_DEPT and combo_box name is combo...........
DECLARE
  STATUS    NUMBER;
  Problem   EXCEPTION;
BEGIN
  STATUS  := POPULATE_GROUP ('RG_DEPT');
  IF STATUS <> 0 THEN
    RAISE problem;
  ELSE
    POPULATE_LIST ('combo', 'RG_DEPT');
  END IF;
EXCEPTION
  WHEN problem THEN
    message ('We have a problem to query the PRODUCT table.');
END;

Showing error like....... "Invalid record group for list population";
wat would be the error please let me know.......

Please do ur best

thanks

regards,
jame

[Updated on: Thu, 23 August 2007 20:30] by Moderator

Report message to a moderator

Re: Storing data into the combo box [message #261864 is a reply to message #261207] Thu, 23 August 2007 20:23 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
@sispk6

Not according to the 9i Forms reference manual.

David
Re: Storing data into the combo box [message #261865 is a reply to message #261864] Thu, 23 August 2007 20:47 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Search this forum for 'populate_list'. I think you have your parameters in the wrong order.

David
Re: Storing data into the combo box [message #262304 is a reply to message #260833] Sun, 26 August 2007 01:52 Go to previous message
hemavb
Messages: 103
Registered: May 2007
Location: Dubai , UAE
Senior Member
check for two things...

If your parameters are in the right order
OR
what is the data size of your combo box and that of the data that you are passing to it.

The length of the column, that is to take the VALUE of the combo list element, should be lesser than or equal to the combo box data length.
Previous Topic: The data don't be keep!
Next Topic: Email in oracle
Goto Forum:
  


Current Time: Fri Sep 27 04:27:29 CDT 2024