Re: How to createa nd display list elements for a combo box at runtime?

From: Rob Zijlstra <rj.zijlstra_at_tiscali.nl>
Date: Sat, 19 Nov 2005 16:55:07 +0100
Message-ID: <6phun11n3il2q755tpin8u8m41v6fa2i6k_at_4ax.com>


On 17 Nov 2005 19:53:32 -0800, "preeti" <shwethanrao_at_gmail.com> wrote:

>1) i am using oracle 10g form builder.
>2) I am using record group.
>
>In the when_new_form_instance trigger, I have put the following code.
>
>declare
>rg_name varchar2(40):='r_area_record1';
>rg_id Recordgroup;
>LIST_ID ITEM;
>errcode NUMBER;
>begin
>rg_id:=Find_Group(rg_name);
>if Id_null(rg_id)then
>rg_id :=Create_group_from_query(rg_name,
>'select research_area from research_info
>where proff_id= 9');
>LIST_ID:=FIND_ITEM('TRY_BLOCK.TRY');
>end if;
>errcode:=populate_group(rg_id);
>POPULATE_LIST(LIST_ID,RG_ID);
>end;
>
>When I run the form, I am not getting any errors, but it is not
>displaying the list.
>
>Please let me know if you need any further details.
>
>Thank you

Preeti,

When you are using a combo box, you do not need an LOV. ( At least the last time I made one)

  1. Your query should return two values for a combo-box , both varchar2. ( one value will be the value of the combo-box, the other will be displayed)

like this:

declare

      rg_name varchar2(40):='r_area_record1';
     rg_id Recordgroup;
     LIST_ID ITEM;

    errcode NUMBER;
begin

   rg_id:=Find_Group(rg_name);
   if Id_null(rg_id)
  then

     rg_id :=Create_group_from_query(rg_name, 
                      'select VC_ID , research_area from research_info
                      where proff_id= 9');
     LIST_ID:=FIND_ITEM('TRY_BLOCK.TRY');
  end if;
  --
  errcode:=populate_group(rg_id);
  POPULATE_LIST(LIST_ID,RG_ID);
end;

Where VC_ID is preferably the PK of table research_info. If this PK is a number then take to_char(....


If you use a lot of combo boxes, it is handy to pack everything in a pll procedure ( Here Maak_Lijst):

PROCEDURE Maak_Lijst( P_ItemNaam Varchar2, P_SqlString varchar2) IS /* maakt de TList van P_ItemNaam in orde:

    property sheet of the item:

  1. required = 'N'
  2. elements in list: click it, give some value in the lower box 'List Item Value' , for example Q
  3. item - type = list item
  4. item - lijststijl = combo box */ list_id ITEM; rg_id RecordGroup;
    • make a random name for the RG rg_naam Varchar2(40) := 'RG' || to_char(abs(dbms_random.random)) ; errcode Number; BEGIN rg_id := Find_Group( rg_naam); -- if id_Null(rg_id) then rg_id := Create_Group_From_Query( rg_naam, P_SqlString); end if; -- errcode := Populate_Group(rg_id); -- Populate_List( P_ItemNaam ,rg_id); exception when others then
      • log-it, must be YOUR code bo_log.ins('Maak_Lijst',sqlerrm(sqlcode)); END;
Call it like:
Maak_Lijst ( 'TRY_BLOCK.TRY', '
                    'select VC_ID , research_area from research_info
                      where proff_id= 9');

No more code is needed then, the procedure will do everything what is needed.

HTH, now my weekend will start....

Rob Zijlstra

Best Regards

Rob Zijlstra Received on Sat Nov 19 2005 - 16:55:07 CET

Original text of this message