-
Copyrights 2010 - Online Training Oracle Applications. All Rights Reserved.
|
Trigger is collection of SQL , PL/SQL and Form coding statements executed based on the event. Triggers can be created in three levels.
Form Level Triggers
Block level triggers
Item level triggers
Button
Radio group
Check box
List Item
Lets workout with few examples Now, create form based on student table ( using data block and layout wizard ) Select ON-LOGON Ok Message ( ) -- is a built_in, used to display message Similarly , Lets us create ON_LOGOUT trigger ( It is a form level trigger). Create a new trigger under STUDENT form. Click on compile button. So, we have created two triggers in our form.
Program Compile Module As we know, ON-LOGON trigger is the first trigger which is fired, We get a message “Welcome to my Application” at the bottom of the form.
Select Action in Menu Bar Exit , ON-LOGOUT trigger is executed.
Now, lets make few changes in the existing form ( STUDENT.FMB)
Close the trigger. We get welcome message in pop up window. Example of WHEN-VALIDATE-ITEM trigger ( Trigger fires when item value is changed). Create a table EMPONE in our database ( It is same as standard EMP table). In Object Navigator , Write the following code in WHEN-VALIDATE-ITEM trigger begin Let’s create another trigger ( WHEN-VALIDATE-ITEM )which checks for valid salary. begin Raise form_trigger_failure : Note So, we have create two trigger. Both are Item level triggers. Program à Compile Module In the form run time environment ( Oracle Application Server Form Services ) Click on OK à Cursor will be back on ENAME item. Lets check the trigger on SAL Item. Order of Execution of triggers at runtime
Hierarchy of block level triggers
Hierarchy of Item level triggers
|