17 Jan 2017

Dynamic List Items

CREATE THE FORM WITH TWO LIST ITEMS. IN ELEMENTS LIST PROPERTY SET TO BE NULL.
CREATE ONE PUSH BUTTON , HAVE FOLLOWING CODE.
DECLARE
                RG_ID    RECORDGROUP;                               RG_NAME VARCHAR2(20) := 'RG_DEPT';
                GC_ID1                 GROUPCOLUMN;                              GC_ID2                 GROUPCOLUMN;
                ROW_CNT NUMBER := 0;
BEGIN
                IF :DEPT_LIST IS NULL THEN
                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 TO DERIVE A HANDLE OR INTERNAL ID */
                RG_ID := CREATE_GROUP(RG_NAME);
                                IF ID_NULL(RG_ID) THEN
                                                MESSAGE('ERR: CREATING RECORD GROUP '||RG_NAME);
                                                RAISE FORM_TRIGGER_FAILURE;
                                END IF;
/* ADD TWO GROUP COLUMNS, DEPTNO AND DNAME */
                GC_ID1 := ADD_GROUP_COLUMN(RG_ID, 'DNAME', CHAR_COLUMN,20);
                GC_ID2 := ADD_GROUP_COLUMN(RG_ID, 'DEPTNO',CHAR_COLUMN,05);
/* CREATE ROWS AND POPULATE THEM IN A LOOP. */
                FOR I IN (SELECT DNAME,DEPTNO FROM SCOTT.DEPT) LOOP
                                ROW_CNT :=ROW_CNT+1;
                                ADD_GROUP_ROW(RG_ID, END_OF_GROUP);
                                SET_GROUP_CHAR_CELL(GC_ID1, ROW_CNT, I.DNAME);
                                SET_GROUP_CHAR_CELL(GC_ID2, ROW_CNT, TO_CHAR(I.DEPTNO));
                END LOOP;
                POPULATE_LIST('DEPT_LIST', RG_ID);
                END;

                ELSIF :DEPT_LIST IS NOT NULL THEN

                BEGIN  
                RG_NAME := 'JOB_GROUP';         
                RG_ID := FIND_GROUP(RG_NAME);
                IF NOT ID_NULL(RG_ID) THEN
                                DELETE_GROUP(RG_ID);
                END IF;
/* CREATE THE RECORD GROUP TO DERIVE A HANDLE OR INTERNAL ID */
                RG_ID := CREATE_GROUP(RG_NAME);
                                IF ID_NULL(RG_ID) THEN
                                                MESSAGE('ERR: CREATING RECORD GROUP '||RG_NAME);
                                                RAISE FORM_TRIGGER_FAILURE;
                                END IF;
/* ADD TWO GROUP COLUMNS, DEPTNO AND DNAME */
                GC_ID1 := ADD_GROUP_COLUMN(RG_ID, 'DESIGNATION', CHAR_COLUMN,20);
                GC_ID2 := ADD_GROUP_COLUMN(RG_ID, 'JOB',CHAR_COLUMN,05);
/* CREATE ROWS AND POPULATE THEM IN A LOOP. */
                FOR I IN (SELECT INITCAP(JOB) DESIG,JOB FROM SCOTT.EMP
                          WHERE DEPTNO=:DEPT_LIST) LOOP
                                ROW_CNT :=ROW_CNT+1;
                                ADD_GROUP_ROW(RG_ID, END_OF_GROUP);
                                SET_GROUP_CHAR_CELL(GC_ID1, ROW_CNT, I.DESIG);
                                SET_GROUP_CHAR_CELL(GC_ID2, ROW_CNT, I.JOB);
                END LOOP;
                POPULATE_LIST('JOB_LIST', RG_ID);
                END;
                END IF;
END;
                

No comments:

Post a Comment