Home » Developer & Programmer » Forms » Can not select different values from the list item (Forms 10g, Oracle database 9i, Windows XP)
Can not select different values from the list item [message #441962] Thu, 04 February 2010 02:16 Go to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I believe I need some assistance ...

I have created a list item (poplist) and populated it programatically; it works OK:
declare
	group_id   recordgroup;
	list_id    item         := find_item('novi_ugovor.list_vugid');
	status     number;
	rg_name    varchar2(40) := 'recgroup';
	l_sql      varchar2(1000);
begin

	group_id := find_group(rg_name);
	
	if not id_null (group_id) then
	   delete_group(group_id);
	end if;

	l_sql := 'select id, ''vrsta'' from vrsta';
	
	group_id := create_group_from_query (rg_name, l_sql);
	clear_list(list_id);
	status   := populate_group(rg_name);
	populate_list(list_id, group_id);
end;

When run, form does its job and creates a list (list item's button is marked with red color, and here are all values it was supposed to return):

/forum/fa/7410/0/

Now I select number (for example) 27. How do I do that? I move mouse pointer to "27" (it turns blue)

/forum/fa/7411/0/

and push the left mouse button. The result is unexpected:

/forum/fa/7412/0/

8 instead of 27? Why? The same goes for any other choice - I always get 8 and can't select any other value (except for "nothing" (i.e. leave it empty).


Here are list item's properties:

/forum/fa/7415/0/



Static values in list item work just fine and return different values. What did I do wrong?
Re: Can not select different values from the list item [message #441977 is a reply to message #441962] Thu, 04 February 2010 03:46 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
Isn't that query going to give every element the same value?
That being the case how is forms going to know what to display for the actual value stored?
Re: Can not select different values from the list item [message #441983 is a reply to message #441977] Thu, 04 February 2010 03:57 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I think I understand; I should (in a loop, for example) ADD_LIST_ELEMENT for every value returned by that SELECT statement.

Thank you, CM!
Re: Can not select different values from the list item [message #441990 is a reply to message #441962] Thu, 04 February 2010 04:27 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
Wouldn't have thought that'd be necessary but I'm not completely sure what you're trying to achieve.
What do you want to store in the db? the id?
and what's vrsta when it's at home?
Re: Can not select different values from the list item [message #441992 is a reply to message #441990] Thu, 04 February 2010 04:39 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Nothing is to be stored; this is just a part of a little bit wider story, where IDs are calculated upon certain conditions and manipulated in the form. Everything was fine in SQL*Plus, but not within the list item.

Finally, I don't even need the record group; this code does the job (at least, so far):
declare
  list_id    item := find_item('novi_ugovor.list_vug');
begin
  clear_list(list_id);

  for cur_r in (select rownum rn, id from vrsta) loop
    add_list_element(list_id, cur_r.rn, cur_r.id, cur_r.id);
  end loop;
end;

Thank you again!
Re: Can not select different values from the list item [message #441994 is a reply to message #441962] Thu, 04 February 2010 04:54 Go to previous message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
You might not be storing it in the db, guessing it's not a db item, but the list item has to hold a value (which is the list_value) and that value doesn't have to be the same as what's on screen (as that's the list_label).
If you change your select in the original code to:
'select id, id from vrsta';

you'll get the same results as your new code.
As when you use a record_group the first item in the select becomes the list_label and second becomes the list_value.
You ended up with the same list_value for each so it got confused, and since it'll be the list_value you get when you check the value of the item in code it really needs to be different.
Previous Topic: query field based on detail block but on main block canvas
Next Topic: Tree node icons
Goto Forum:
  


Current Time: Fri Sep 20 11:52:37 CDT 2024