|
|
Re: LOV does not display [message #144421 is a reply to message #144415] |
Wed, 26 October 2005 07:17 |
tornup
Messages: 13 Registered: February 2005 Location: Trinidad
|
Junior Member |
|
|
The following code is placed in when-button-pressed trigger
=============================================================
DECLARE
pressed BOOLEAN;
lov_id LOV;
rg_name VARCHAR2(15) := 'RG_AREA_CD';
rg_id RECORDGROUP;
code_col GROUPCOLUMN;
desc_col GROUPCOLUMN;
temp_cnt NUMBER(5) := 0;
words VARCHAR2(120);
errcode NUMBER;
last_row NUMBER;
BEGIN
rg_id := Find_Group(rg_name);
IF (id_null(rg_id)) THEN
--Create new record group
rg_id := Create_Group(rg_name);
--Add columns to record group
code_col := Add_Group_Column(rg_id, 'Codes', NUMBER_COLUMN);
desc_col := Add_Group_Column(rg_id, 'Description', CHAR_COLUMN, 120);
--Get number of area codes in new_office table
SELECT COUNT(DISTINCT off_area_cd)
INTO temp_cnt
FROM new_office
WHERE off_area_cd IS NOT NULL;
--Populate record group
FOR area IN 1..temp_cnt LOOP
-- concatentate service center names
words := area_desc(area);
ADD_GROUP_ROW(rg_id, area);
SET_GROUP_NUMBER_CELL(code_col, area, area);
SET_GROUP_CHAR_CELL(desc_col, area, words);
END LOOP;
lov_id := FIND_LOV('LOV_AREA_FR'); -- find LOV id created at design time
SET_LOV_PROPERTY(lov_id, GROUP_NAME, 'RG_AREA_CD');
pressed := SHOW_LOV(lov_id); -- display LOV
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
MESSAGE('No area codes exists!');
END;
Upd-mod: add code tags.
[Updated on: Wed, 26 October 2005 18:20] by Moderator Report message to a moderator
|
|
|
|
Re: LOV does not display [message #144503 is a reply to message #144499] |
Wed, 26 October 2005 18:40 |
tornup
Messages: 13 Registered: February 2005 Location: Trinidad
|
Junior Member |
|
|
The query is not a simple query. I need to concatenate office names that belong to certain areas, and display them in a LOV.
Example, I need this:
1 A,B,C
2 E,F,G,H
But data is stored in the table as:
1 A
1 B
1 C
...etc
I found a way out, by creating a function to concatenate and a view, running that at the back end. That works fine, but I still want to figure out why the LOV isn't working. Any help will be appreciated.
|
|
|
|
Re: LOV does not display [message #144607 is a reply to message #144517] |
Thu, 27 October 2005 07:06 |
tornup
Messages: 13 Registered: February 2005 Location: Trinidad
|
Junior Member |
|
|
Hi David,
I don't think I explained myself properly. I need an LOV that has 2 columns, one with area codes (1,2,3 etc) and one with office names. Since each area consists of more than one office name, I need to concatenate the office names where area = 1 or 2 etc. The area code will be used in processing data in the form. The office names are just for display purposes.
I understand what you are saying about users not wanting to use the mouse, but this is what they have requested.
The concatenation function works fine (see below)
I have defined the return fields. The strange thing is, I am not getting any errors. When I click on the LOV button, nothing is happening.
================================================================
FUNCTION area_desc(temp_area_cd NUMBER)RETURN VARCHAR2 IS
CURSOR n IS
SELECT DISTINCT (off_name) office_name
FROM new_office
WHERE off_area_cd = temp_area_cd
ORDER BY off_name;
temp_cnt NUMBER(5) := 0;
temp_offnames VARCHAR2(200) := '';
BEGIN
-- Get number of office names returned by cursor n
SELECT COUNT(off_name)
INTO temp_cnt
FROM new_office
WHERE off_area_cd = temp_area_cd;
-- Concatentate office names into single string
FOR offname IN n LOOP
IF (n%ROWCOUNT < temp_cnt) THEN
temp_offnames := temp_offnames||offname.office_name||', ';
ELSE
temp_offnames := temp_offnames||offname.office_name;
EXIT;
END IF;
END LOOP;
-- Display string
RETURN(temp_offnames);
END;
|
|
|
|
Re: LOV does not display [message #144728 is a reply to message #144607] |
Thu, 27 October 2005 19:29 |
|
djmartin
Messages: 10181 Registered: March 2005 Location: Surges Bay TAS Australia
|
Senior Member Account Moderator |
|
|
In you when-button-pressed trigger you have all the code inside the IF 'positive' logic. Have a look at the documentation for create_group and delete_group. I expect that you need to delete the group and then recreate it. But hey, I don't do things this way.
Why not design a record_group in Forms Builder based on:select distinct area, area_desc(area)
from new_office
order by 1; then base your LOV on this record group.
David
[Updated on: Thu, 27 October 2005 19:30] Report message to a moderator
|
|
|
|
|