Oracle Forms之動態List Item Value

在Forms開發中,很多時候都會用到List提供特定的值給用戶進行選擇。

而本文討論的是 如何動態的添加List的值。

原理就是通過record group

具體可參考官方文檔:POPULATE_LIST Built-in

POPULATE_LIST Built-in

Description

Removes the contents of the current list and populates the list with the values from a record group. The record group must be created at runtime and it must have the following two column (VARCHAR2) structure:

Column 1Column 2:

the list label the list value


Syntax

PROCEDURE POPULATE_LIST(list_id ITEM, recgrp_id RecordGroup);

PROCEDURE POPULATE_LIST(list_id ITEM, recgrp_name VARCHAR2);

PROCEDURE POPULATE_LIST(list_name VARCHAR2, recgrp_id RecordGroup);

PROCEDURE POPULATE_LIST(list_name VARCHAR2, recgrp_name VARCHAR2);

Built-in Type unrestricted procedure

Enter Query Mode yes

Parameters

list_id  Specifies the unique ID that Oracle Forms assigns when it creates the list item. Use the FIND_ITEM built-in to return the ID to an appropriately typed variable. The data type of the ID is ITEM. 

list_name  The name you gave to the list item when you created it. The data type of the name is VARCHAR2.

recgrp_id  Specifies the unique ID that Oracle Forms assigns when it creates the record group. The data type of the ID is RecordGroup. 

recgrp_name  The VARCHAR2 name you gave to the record group when you created it.

Usage Notes

             Do not use the POPULATE_LIST built-in if the Mapping of Other Values property is defined and there are queried records in the block. Doing so may cause Oracle Forms to be unable to display records that have already been fetched.For example, assume that a list item contains the values A, B, and C and the Mapping of Other Values property is defined. Assume also that these values have been fetched from the database (a query is open). At this point, if you populate the list using POPULATE_LIST, an error will occur because Oracle Forms will attempt to display the previously fetched values (A, B, and C), but will be unable to because these values were removed from the list and replaced with new values.

            Before populating a list, close any open queries. Use the ABORT_QUERY built-in to close an open query.

設置List Item

               1. 在Property Palette(key:F4)中設置<Item Type> 屬性爲List Item,<Subclass Information>爲List

新建Record Groups

               2.Record Groups的數據來源,只能對應List的兩列 也就是必須控制爲兩個欄位


添加Triggers

             3.在Block級或Item級的Trigger中添加如下代碼:

BEGIN 
--RETRIEVE_LIST(list_id, 'RECGRP_ONE'); 
CLEAR_LIST('Block.Item_name'); 
POPULATE_LIST('Block.Item_name', 'Group_Name'); 
END; 






發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章