Oracle Forms Triggers
Trigger is a set of statements that executed when an action take a place.
There is some types depends on event level (Form, Block, Record, Item) for Triggers,
if the same trigger found in more than one level then the lowest level will run ex: when_validate_item
on (form, block, item) then only the item level will run. The second types of triggers depends
on the time for run (pre, when, post, on, custom) each type is different from other in time to run.
Pre: before the chosen event ex: pre_query (before execute the query).
When: during the event ex: when_validate_item (when item data validation).
Post: after the event ex: Post_Query (after execution of query).
On: this type unpredictable cause we don’t know when it will run, may during a trigger execution or just when you try to enter data in protected field.
Custom: you can add a custom trigger and call it from any were (execute_trigger(‘custome_tri’);)
Here are some of the most important trigger can the programmer use in any program:
trigger
exe
purpose
level
ex
1
When_new_form_instance
1
To initial some variable values
form
:global.datetime:=sysdate;
:time_text:=sysdate;
:user_text:=user;
2
On_error
1
To handle error during run time, or to display it in good way to user.
form
If error_code = 14015 then
Message('錯誤');
Message('錯誤');
End if;
3
Pre_insert, pre_update
1
To set some fields value implicitly in code.
Form, Block
:username := user;
4
Post_query
Return rows
To get description for code field.
Block
Select ename into :name_txt
From emp where empno=:empno;
5
Pre_query
1
To set default where to block
block
Set_block_property ('block1',default_where,'deptno=1');
6
When_new_record_instance
1
To set initial values to block items when add new record.
block
Select max(empno)+1 into :empno
From emp;
7
When_validate_item
1
To get description for the code entered in item.
item
Select ename into :name_txt
From emp where empno=:empno;
8
Post_change
1
Executes only when item value is changed.
item
Select ename into :name_txt
From emp where empno=:empno;
**Note: we preferred When_validate_item, cause it’s execute every time in item.
9
Key_next_item
1
Executes when you press enter-key after entered value in item.
item
Select ename into :name_txt
From emp where empno=:empno;
**Note: it’s executes instead of going to the next item (:name_txt).
10
When_button_pressed
1
Executes when mouse click or by keyboard enter-key.
item
Message('clicked');pause;
**Note: set property MOUSE NAVIGATE to NO
11
When_checkbox_changed
1
When you change the selection of radio, checkbox.
item
If :box = 1 then
Message('open');
End if;
System Variables | ||
1 | : System.current_block | Get the current block. |
2 | : SYSTEM.current_item | Get the current item. |
3 | :System.block_status | New, enter-query, changed |
留言列表