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

About Triggers and Events

Triggers are blocks of PL/SQL code that are written to perform tasks when a specific event occurs within an application. In effect, a Oracle Forms trigger is an event-handler written in PL/SQL to augment (or occasionally replace) the default processing behavior. Every trigger has a name, and contains one or more PL/SQL statements. A trigger encapsulates PL/SQL code so that it can be associated with an event and executed and maintained as a distinct object.

When Oracle Forms responds to an event by executing the code in a trigger, that trigger is said to have "fired." Most form applications include numerous triggers that fire in response to a variety of events.

A trigger must be attached to a specific object in the form, either an item, a block, or the form itself. The object to which a trigger is attached defines the scope of the trigger, and so helps Oracle Forms decide which trigger to fire when the corresponding event occurs. Not all triggers are relevant to all objects. For example a When-Button-Pressed trigger would not be attached to a display item.

Trigger names correspond to pre-defined runtime events. For example, the When-Button-Pressed trigger corresponds to the Button Pressed event, which occurs when an operator selects a button. The name of the trigger establishes the association between the event and the trigger code; when operators click on a button with a mouse, Oracle Forms responds by executing the code in the When-Button-Pressed trigger.

For example, in a form with three buttons, each button has a When-Button-Pressed trigger attached to it, and each trigger contains different PL/SQL statements. When an operator selects one of the buttons, that is, when the Button Pressed event occurs, Oracle Forms responds by firing only the When-Button-Pressed trigger attached to the selected button. The When-Button-Pressed triggers attached to the other two buttons are outside the scope of the event, and so are ignored.


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

Creating a trigger in the PL/SQL Editor

Creating a trigger in the Layout Editor

Creating a trigger using Smart Triggers