P. 1
Oracle Forms

Oracle Forms

|Views: 1,470|Likes:
Published by satya1401

More info:

Published by: satya1401 on Dec 30, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

02/23/2013

pdf

text

original

Navigational triggers fire in response to navigational events. For instance, when the operator
clicks on a text item in another block, navigational events occur as Form Builder moves the
input focus from the current item to the target item.

I ] PRE- AND POST- TRIGGERS

Fire as Form Builder navigates internally through different levels of the object hierarchy.

When Do Pre- and Post-Navigation Triggers Fire?

The Pre- and Post- navigation triggers fire during navigation, that is just before entry
to or just after exit from the object specified as part of the trigger name.

Example

The Pre-Text-Item trigger fires just before entering a text item.

When Do Navigation Triggers Not Fire?

The Pre- and Post- navigation triggers do not fire if they belong to a unit that is smaller than the current
validation unit. For instance, if the validation unit is Record, Pre- and Post-Text-Item triggers do not fire.

What Happens When a Navigation Trigger Fails?

Shik Mahamood Ali

54

If a Pre- or Post navigation trigger fails, the input focus returns to its initial location (where it was prior
to the trigger firing). To the user, it appears that the input focus has not moved at all.

1. Pre-Form

Perform an action just before Form Builder navigates to the form from "outside" the form,
such as at form startup.

IF not (DBMS_SESSION.IS_ROLE_ENABLED(’ADMINISTRATIVE’) or
(DBMS_SESSION.IS_ROLE_ENABLED(’TECHNICAL’) THEN
MESSAGE(’You are not authorized to run this application’);
PAUSE;
RAISE form_trigger_failure;

END IF;

2. Pre-Block

Perform an action before Form Builder navigates to the block level from the form level.

Fires during the Enter the Block process, during navigation from one block to another.

Usage Notes:

Use a Pre–Block trigger to:
• Allow or disallow access to a block
• Set variable values

Disabling stock_button when leaving CONTROL block:

Shik Mahamood Ali

55

begin

SET_ITEM_PROPERTY(’CONTROL.stock_button’, enabled, property_false);

End;

3. Pre-Record

Perform an action before Form Builder navigates to the record level from the block level.

Usage Notes:

• Fires during the Enter the Record process, during navigation to a different record.

• Use a Pre–Record trigger to keep a running total.

The following trigger prevents the user from entering a new record given some dynamic condition and
the status of SYSTEM.RECORD_STATUS evaluating to NEW.

IF (( dynamic–condition) AND :System.Record_Status = ’NEW’) THEN
RAISE Form_Trigger_Failure;

END IF;

4. Pre-Text-Item

Perform an action before Form Builder navigates to a text item from the record level.

Usage Notes:

Use a Pre–Text–Item trigger to perform the following types of tasks:

• Derive a complex default value, based on other items previously
entered into the same record.
Record the current value of the text item for future reference, and
• store that value in a global variable or form parameter.

5. Post-Form

Perform an action before Form Builder navigates to "outside" the form, such as when exiting
the form.

Fires during the Leave the Form process, when a form is exited.

Usage Notes:

You can use a Post–Form trigger for the following tasks:

• To clean up the form before exiting. For example, use a Post–Form trigger to erase any
global variables that the form no longer requires.
• To display a message to the operator upon form exit.

This trigger does not fire when the form is exited abnormally, for example, if validation fails in
the form.

6. Post-Block

Manipulate the current record when Form Builder leaves a block and navigates to the form
level.

Usage Notes:

Shik Mahamood Ali

56

• Use a Post–Block trigger to validate the block’s current record; that is, the record that had input focus when
the Leave the Block event occurred.
• You might also use this trigger to test a condition and prevent the user from leaving a block based on that

condition.

Example

Set_item_property (‘control.cmdsave’, enabled, property_false);

7. Post-Record

Manipulate a record when Form Builder leaves a record and navigates to the block level.

Fires during the Leave the Record process. Specifically, the Post–Record trigger fires whenever
the operator or the application moves the input focus from one record to another. The Leave
the Record process can occur as a result of numerous operations, including INSERT_RECORD,
DELETE_RECORD, NEXT_RECORD, NEXT_BLOCK, CREATE_RECORD, PREVIOUS_BLOCK, etc.

Usage Notes:

Use a Post–Record trigger when you want to perform an action whenever the operator or the
application moves the input focus from one record to another. For example, if you want to set
a visual attribute for an item as the operator scrolls down through a set of records, you can do
so from within this trigger.

Example:

/* ** Built–in: NEXT_RECORD
** Example: If the current item is the last item in the ** block, then skip to the next record instead of
** the default of going back to the first item in ** the same block
** Trigger: Key–Next–Item */

DECLARE

cur_itm VARCHAR2(80) := :System.Cursor_Item;
cur_blk VARCHAR2(80) := :System.Cursor_Block;
lst_itm VARCHAR2(80);

BEGIN

lst_itm := cur_blk||’.’||Get_Block_Property(cur_blk,LAST_ITEM);
IF cur_itm = lst_itm THEN
Next_Record;

ELSE

Next_Item;

END IF;

END;

8. Post-Text-Item

Manipulate an item when Form Builder leaves a text item and navigates to the record level.

Fires during the Leave the Item process for a text item. Specifically, this trigger fires when the
input focus moves from a text item to any other item.

II] WHEN-NEW-INSTANCE-TRIGGERS

Shik Mahamood Ali

57

Fire at the end of a navigational sequence that places the input focus on a different item.
Specifically, these triggers fire just after Form Builder moves the input focus to a different
item, when the form returns to a quiet state to wait for operator input.

When Do When-New- “object”-Instance Triggers Fire?

The When-New-”object”-Instance triggers fire immediately after navigation to the object specified as part
of the trigger name.

Example

The When-New-Item-Instance trigger fires immediately after navigation to a new instance of an item.

1. When-New-Form-Instance

Perform an action at form start-up. (Occurs after the Pre-Form trigger fires).

Perform a query of all orders, when the ORDERS form is run, by including the following code in your
When-New-Form-Instance trigger:

1a.

EXECUTE_QUERY;

1b.

BEGIN

DEFAULT_VALUE(’’, ’'GLOBAL.where_cls’);
SET_BLOCK_PROPERTY(’prod_lov_blk’, DEFAULT_WHERE,:GLOBAL.where_cls);
EXECUTE_QUERY;

END;

1c.

BEGIN

EXECUTE_QUERY;
:GLOBAL.width_win_order := GET_WINDOW_PROPERTY(’win_order’, WIDTH);
:GLOBAL.height_win_order := GET_WINDOW_PROPERTY(’win_order’,HEIGHT);
:GLOBAL.width_win_inventory := GET_WINDOW_PROPERTY(’win_inventory’,WIDTH);
:GLOBAL.height_win_inventory := GET_WINDOW_PROPERTY(’win_inventory’,HEIGHT);

END;

1d. When-New-Form-Instance Trigger at Form Level

BEGIN
SET_WINDOW_PROPERTY( forms_mdi_window, WINDOW_STATE, MAXIMIZE );
SET_WINDOW_PROPERTY( forms_mdi_window, TITLE, ’Summit Sporting Goods Application’);
END;

Example

This code could be used in a WHEN-NEW-FORM-INSTANCE trigger to initially populate the hierarchical
tree with data. The example locates the hierarchical tree first. Then, a record group is created and the
hierarchical tree is populated.

DECLARE

htree ITEM;
v_ignore NUMBER;
rg_emps RECORDGROUP;

Shik Mahamood Ali

58

BEGIN

htree := Find_Item('tree_block.htree3');
rg_emps := Create_Group_From_Query('rg_emps',’select 1, level, ename, NULL, to_char(empno) ’
||' from emp ' ||'connect by prior empno = mgr ' ||’start with job = ’’PRESIDENT’’’);
v_ignore := Populate_Group(rg_emps);
Ftree.Set_Tree_Property(htree, Ftree.RECORD_GROUP, rg_emps);

END;

2. When-New-Block-Instance

Perform an action immediately after the input focus moves to an item in a block other than the
block that previously had input focus.

Usage Notes:

Use a When–New–Block–Instance trigger to perform an action every time Oracle Forms
instantiates a new block.

Example

The following example of a When-New-Block-Instance trigger conditionally sets the DELETE ALLOWED
property to FALSE.

IF GET_APPLICATION_PROPERTY(username) = ’SCOTT’ THEN
SET_BLOCK_PROPERTY(’S_ITEM’,DELETE_ALLOWED, PROPERTY_FALSE);

END IF;

3. When-New-Record-Instance

Perform an action immediately after the input focus moves to an item in a different record. If
the new record is in a different block, fires after the When-New-Block-Instance trigger, but
before the When-New-Item-Instance trigger.

Usage Notes:

Use a When–New–Record–Instance trigger to perform an action every time Oracle Forms instantiates a
new record. For example, when an operator presses [Down] to scroll through a set of records, Oracle
Forms fires this trigger each time the input focus moves to the next record, in other words, each time
Oracle Forms instantiates a new record in the block.

Example

The Cursor arrives in each record of the S_Item block, and populates the product_image item
with a picture of the products, if one exists

1] Declare

Filename varchar2(20);

Begin

Filename:=get_product_image(:S_ITEM.PRODUCT_ID);
If Filename= ‘ No file’ then
Null;

Else

Read_Image_File(filename,’tiff’,’S_ITEM.product_image’);

End if

End;

2]

1.a Example: Brings up the debugging window for a particular ** value of the ’JOB’ item anytime the user
changes records.*/

BEGIN

IF :Emp.Job = ’CLERK’ THEN
Break;

Shik Mahamood Ali

59

Call_Form(’clerk_timesheet’);
Break;

END IF;

END;

3.]

BEGIN

IF (:global.cancel_query = 'Y' and :system.mode = 'ENTER-QUERY') THEN
Exit_Form;
:global.cancel_query = 'N';

END IF;

END;

4.When-New-Item-Instance

Fires when the input focus moves to an item. Specifically, it fires after navigation to an item,
when Form Builder is ready to accept input in an item that is different than the item that
previously had input focus.

Perform an action immediately after the input focus moves to a different item. If the new item
is in a different block, fires after the When-New-Block-Instance trigger.

Usage Notes

Use a When-New-Item-Instance trigger to perform an action whenever an item gets input focus. The When-
New-Item-Instance trigger is especially useful for calling restricted (navigational) built-ins.

1]

IF CHECKBOX_CHECKED(’S_ORD.order_filled’)THEN
SET_ITEM_PROPERTY(’S_ORD.date_shipped’,UPDATE_ALLOWED, property_true);
GO_ITEM(’S_ORD.date_shipped’);

END IF;

2] Built–in: CLEAR_ITEM - Example: Clear the current item if it does not represent ** the first day of a

month.

BEGIN

IF TO_CHAR(:Emp.Hiredate,’DD’) <> ’01’ THEN
Clear_Item;
Message(’This date must be of the form 01–MON–YY’);

END IF;

END;

3]. BEGIN

IF :Emp.Empno IS NOT NULL THEN
:Global.Employee_Id := :Emp.Empno;
Clear_Block(No_Validate);

END IF;

END;

4]. Assume that you want Oracle Forms to display an LOV when the operator enters query mode and the
input focus is in a particular text item. The following trigger accomplishes that operation.

BEGIN

IF :System.Cursor_Item = ’EMP.EMPNO’ and :System.Mode = ’ENTER–QUERY’ THEN
IF NOT Show_Lov(’my_lov’) THEN
RAISE Form_Trigger_Failure;

End if;

END IF;

Shik Mahamood Ali

60

END;

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->