A script-enabled browser is required for this page to function properly.

Trigger Definition Level and Scope

When a trigger is created it is attached to a specific object, either an item, a block, or the form itself. The object to which a trigger is attached determines the trigger's definition level in the object hierarchy. For example, a trigger attached to a block named Customer has a definition level of block, and is said to be a "block-level trigger."

A trigger's definition level is important because it determines the trigger's scope. The scope of a trigger is its domain within the Oracle Forms object hierarchy, and determines where an event must occur for the trigger to respond to it.

Trigger scope is defined as the trigger definition level (form, block, or item) and below. Thus, a block-level trigger fires if the trigger event occurs within that block, but it does not fire if the same event occurs in some other block.

Consider the When-New-Item-Instance trigger. This trigger fires in response to the Enter the Item event, which occurs when the operator or the application navigates to a different item. If the When-New-Item-Instance trigger is attached to a text item, it fires only when the operator enters that particular item. If the same When-New-Item-Instance trigger were attached to the block, it would fire when the operator entered any item in that block. Similarly, if the trigger were attached to the form, it would fire when the operator entered any item in any block in the form.

Precedence of Triggers that Respond to the Same Event

It is common to define triggers at different levels that respond to the same event. When an event occurs that is within the scope of more than one trigger, the trigger with the lowest definition level takes precedence.

For example, you might attach a When-New-Item-Instance trigger to a block, and another When-New-Item-Instance trigger to a text item in that block. When the operator navigates to the text item, the item-level trigger fires, and the block-level trigger is ignored.

Restrictions on Trigger Definition Levels

Some triggers can be defined only at a particular definition level. For example, the When-Validate-Record trigger, which fires when the Validate the Record event occurs, is only valid if attached to a block or to the form—it cannot be attached to an item. Most triggers, however, can be defined at the form, block or item level, and it is up to you to select the appropriate definition level to achieve the desired functionality.


Types of Events

Trigger Definition Level and Scope

Creating a trigger in the Object Navigator

Setting trigger properties

About writing trigger code

About compiling triggers

About writing SQL statements in triggers

Overview of trigger categories