Setting properties per record in Forms MRB
This is probably described many times before, but you just can’t have enough example code snippets.
Imagine you want to restrict users to update records which end-dates are in the past in a Multi record block. Strangely, there is no way you can set the property for a record at once, so each item’s Update Allowed property must be set seperately. This can be done with the Set_Item_Instance_Property built-in which only affects the current record in the multi record block.
The code in the Post-query trigger might look something like this:
DECLARE lv_itemname VARCHAR2( 200); BEGIN IF :block.enddate < sysdate<br /> THEN<br /> lv_itemname := Get_Block_Property( 'BLOCK', First_Item ) ;<br /> WHILE ( lv_itemname IS NOT NULL )<br /> LOOP<br /> lv_itemname := 'block.'||lv_itemname;<br /> IF Get_Item_Property( lv_itemname, displayed ) = 'TRUE'<br /> AND Get_Item_Property( lv_itemname, ENABLED ) = 'TRUE'<br /> AND ( Get_Item_Property( lv_itemname, Item_type ) = 'CHECKBOX'<br /> OR Get_Item_Property( lv_itemname, Item_type ) = 'TEXT ITEM'<br /> OR Get_Item_Property( lv_itemname, Item_type ) = 'LIST'<br /> )<br /> THEN<br /> Set_Item_Instance_Property<br /> ( lv_itemname<br /> , CURRENT_RECORD<br /> , Update_allowed<br /> , Property_False<br /> ) ;<br /> END IF ;<br /> --<br /> END IF ;<br /> lv_itemname := Get_Item_Property( lv_itemname, NEXTITEM );<br /> --<br /> END LOOP ;<br /> --<br /> END IF ; END;<br />
I had to add some code to make sure only displayed items of specific types had their properties altered, thus avoiding errors concerning item types that are not displayed or of inappropriate type (like buttons). The combination of a loop and the Get_item_property( <item>, NEXTITEM ) lets me loop through all items in the block programmatically.
Remember that the Post-query trigger fires for each record, so the enddate is checked every time a new record is fetched into the block. In the same code the visual attributes (like background color) of individual records can be set.
- WHEN-IMAGE-PRESSED Trigger problem in Oracle Forms 6.0
- Violation of VPD Policy on DML raises FRM-40654 :Record Has Been Changed by Another User error in Oracle Forms
- Another VPD challenge with our Oracle Designer generated Web Forms application: No Data Found when synchronizing server derived values
- Great Presentation on migrating Oracle Forms to ADF Faces at ODTUG 2006
- Great Oracle Forms 'plugin' – multirecord table column resize/sort/move around