Monday, March 26, 2012

How to Dynamically Populate a Pop List ?

People want to know, how they dynamically populate a pop list? Means, At run time pop list will be populate. So there is no hard coded list element. Don't want to wait ?

You are at right place to learn it.

For this example code, i used SCOTT schema and DEPT table. You have to select privilege on the table.

It's a simplest example, First create a non-database block named DUMMY. create an item with type List Item named TXT_LIST. Data type CHAR, Length 30.
Now create a When-New-Form-Instance trigger at form/block level and write down the following code,

DECLARE
    group_id RecordGroup;
    group_name varchar2(10) :='abc';
    status NUMBER;
BEGIN
    group_id := find_group(group_name);
    if not id_null(group_id) then
        delete_group(group_id);
    end if;
   
    group_id := Create_Group_From_Query(group_name,'select DNAME,TO_CHAR(DEPTNO) from DEPT');
/* Select statement must have two column*/
    status := Populate_Group(group_id);
    Populate_List('DUMMY.TXT_LIST',group_id);
END;


Hope it works...

Monday, March 5, 2012

How to check, if it is first record of the block ?

At multiple-record block, you are looking for the record number, where the cursor is. Say, your at record no 5 and you want to know u'r in five. To get this follow the bellow code...

record_no:=GET_BLOCK_PROPERTY('block_name',CURRENT_RECORD);
 
Hope this helps...