Beruflich Dokumente
Kultur Dokumente
Form Triggers
Trigger is collection of SQL , PL/SQL and Form coding statements executed based on the event.
Triggers are executed automatically at run time based on an event.
Trigger
Slno Explanation
1
pre-form Activated before entering into the form.
2
when-new-form-instance Activated whenever the form is ready to accept data from user
3
on-clear-details Activated when form is cleared ( clear screen )
4
post-form Activated when cursor leaves the form.
7
when-timer-expired fired whenever there is a change in system time
Slno
Trigger Explanation
1
pre-block Fired before entering into the block.
2
when-new-block-instance Fried when block is ready to accept input.
3
when-clear-block Fired whe block is cleared.
4
pre-query Fired when executing a query.
5
post-query Fired after executing the query.
6
post-block Fired when cursor leaves the block
7
when-create-record Fired whenever a new record is inserted.
1
pre-text-item Fired before entering into the text item
3
when-new-item-instance Fired when item is ready to accept input
4
when-validate-item Fired when item value is changed
5
when-clear-item Fired when item is cleared
Button
1
when-button-pressed Fired when button is pressed
Radio group
1
when-radio-changed Fired whenever radio group value is changed
Check box
1
when-checkbox-changed Fired whenever checkbox value is changed
List Item
1
when-list-changed Fired when list value is changed
Now, create form based on student table ( using data block and layout wizard )
Save the from with the name STUDENT.FMB
In object navigator of STUDENT.FMB
Create a new trigger under STUDENT form.
Select trigger click on create button
form48
Select ON-LOGON Ok
Write the following code in the trigger
Message (‘Welcome to my Application’);
Logon (‘scott’, ‘tiger@oracle’);
Click on compile button.
You should get a message “Successfully compiled”
form49
form51
Program Compile Module
Program Run Form
form52
In Object Navigator ,
Under data block (EMPONE) à Item ( ENAME) à Create trigger à WHEN-VALIDATE-ITEM
form57
begin
if :ename is null then
message (‘Employee name cannot be blank’);
message(‘ ‘);
raise form_trigger_failure;
end if;
end;
Click on compile button.
You should get confirmation message “successfully compiled”.
form58
Let’s create another trigger ( WHEN-VALIDATE-ITEM )which checks for valid salary.
In Object navigator à under data block ( EMPONE) à under SAL item à Create trigger à WHEN-VALIDATE-
ITEM
begin
if :sal <3000 then
message(‘Employee sal must not be less than 3000’);
message(‘ ‘);
raise form_trigger_failure;
end if;
end;
Click on compile button.
You should get confirmation message “successfully compiled”.
form59
Raise form_trigger_failure :
It stops the user action. Cursor cannot be moved to next item until restriction is satisfied.
It is similar to raise_application_error in database trigger.
Note
Items are referred with : ( COLON ) before them in coding.
So, we have create two trigger. Both are Item level triggers.
One trigger in ENAME item.
Another trigger in SAL item.
form60
In the form run time environment ( Oracle Application Server Form Services )
Enter Empno – 101
Keep the cursor on ENAME ( do not enter anything)
Keep the cursor on JOB item, we get a message “Employee name cannot be blank”
form61
Click on OK à Cursor will be back on ENAME item.
That is the advantage of raise form_trigger_failure.
Cursor cannot be moved to next item until restriction is satisfied.
form62
1. ON-LOGON
2. PRE-FORM
3. WHEN-NEW-FORM-INSTANCE
4. POST-FORM
5. ON-LOGOUT
PRE-TEXT-ITEM
WHEN-NEW-ITEM-INSTANCE
KEY-NEXT-ITEM ( TAB )
POST-TEXT-ITEM
RECENT POSTS
regexpr_instr in oracle
Regexp_replace in oracle
Regexp_like in oracle