Re: How do you load a list item programmatically??

From: Nick Butcher <nickb_at_btinternet.com>
Date: Sun, 3 Dec 2000 16:56:59 -0000
Message-ID: <90du29$8nr$1_at_plutonium.btinternet.com>


"RBR" <ruddyr_at_home.com> wrote in message news:3a23d4ca.12843688_at_News.CIS.DFN.DE...
> On Tue, 21 Nov 2000 22:01:54 +0800, Connor McDonald
> <connor_mcdonald_at_yahoo.com> wrote:
>
> >
> >a) create a record group with "create_group_from_query"
> >b) call populate_list using the record group
> >
> >HTH
>
> I'm trying to do this with Forms 6i at runtime using the
> "create_group_from_query" followed by a populate_list using the record
> group but my list never gets loaded??? I don't get it.
>
> Rob

Here's a generic procedure that I use:
Just pass the name of the list item, the query and, optionally, TRUE/FALSE if you wish to add an 'All' option.

  PROCEDURE fill_list (p_list_item IN VARCHAR2,
                       p_query IN VARCHAR2,
                       p_add_all IN BOOLEAN DEFAULT FALSE) IS
    list_id ITEM;
    group_id RECORDGROUP;
    status NUMBER;
    list_count NUMBER;
  BEGIN
    list_id := FIND_ITEM (p_list_item);
    group_id := CREATE_GROUP_FROM_QUERY ('list_group', p_query);     status := POPULATE_GROUP ('list_group');     POPULATE_LIST (list_id, group_id);
    DELETE_GROUP ('list_group');
    IF p_add_all THEN
      list_count := TO_NUMBER(GET_LIST_ELEMENT_COUNT (list_id));
      ADD_LIST_ELEMENT (list_id, list_count + 1, 'All', '%');
      COPY ('%', p_list_item);
    ELSIF GET_ITEM_PROPERTY (list_id, REQUIRED) = 'TRUE' THEN
      COPY (GET_LIST_ELEMENT_VALUE (list_id, 1), p_list_item);
    END IF;
  END fill_list;

e.g.:

    utilities.fill_list ('block_1.city',

                         'SELECT INITCAP(city_name), city_code '||
                           'FROM cities', TRUE);
The first column selected is what appears in the list item and the second is the list item value. Make sure that the item length is sufficient to hold the longest value in this (second) column.

Regards

Nick Received on Sun Dec 03 2000 - 17:56:59 CET

Original text of this message