Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Dynamic LOV
I am trying to understand how to populate list items dynamically. I am
trying to do this with creating a queryable record group. I put the code in
the key-listval trigger on the deptno field.
The code I tried below (What am I doing wrong?):
DECLARE
RG_ID RECORDGROUP;
RG_NAME VARCHAR2(8) := 'RG_DEPT';
QUERY_STRING VARCHAR2(80) := 'SELECT TO_CHAR(DEPTNO), DNAME FROM DEPT ORDER
BY DNAME';
RET_CODE NUMBER;
BEGIN
/* First check whether the record group already exists.
If yes, delete it.
*/
rg_id := FIND_GROUP(rg_name);
IF NOT ID_NULL(RG_ID) THEN
DELETE_GROUP(RG_ID);
END IF;
/* Create the record group from an input query to derive a handle or
internal id, as well as the column structure
*/
RG_ID := CREATE_GROUP_FROM_QUERY(RG_NAME, QUERY_STRING);
IF ID_NULL(RG_ID) THEN
MESSAGE('ERR: Creating Record Group' || RG_NAME);
RAISE FORM_TRIGGER_FAILURE;
END IF;
/* Populate the created record group with data from the query used to
create the group. This need not be done in a loop.
*/
-- RET_CODE := POPULATE_GROUP_WITH_QUERY(RG_ID, 'SELECT
TO_CHAR(DEPTNO),DNAME FROM DEPT');
RET_CODE := POPULATE_GROUP(RG_ID);
IF (RET_CODE IS NOT NULL AND RET_CODE <> 0) THEN
MESSAGE('ERR: Populating Group');
RAISE FORM_TRIGGER_FAILURE;
END IF;