Oracle10g
Chapter 6:
Creating Custom Forms
Custom form
3.
4.
Form Triggers
Program Units
Self-contained programs
Can be called from PL/SQL triggers
Used to make triggers more
modular, and reuse code within
triggers
Practice1
Employee Name
Employee Salary
Department Name
Return Value
$$TIME$$
$$DATETIME$$
$$DBDATE$$
$$DBTIME$$
$$DBDATETIME$$
Form Triggers
Categories
Block processing
Interface event
Master-detail processing
Message handling
Navigational
Query time
Transactional
Validation
Trigger Timing
PRE
POST
Trigger Scope
Trigger Execution
Hierarchy
Navigational Triggers
User Action
1
2
PRE-FORM
PRE-BLOCK
Result on User
Screen Display
3
Form appears,
but with no
data visible
5
WHEN-NEW-FORM-INSTANCE
WHEN-NEW-BLOCK-INSTANCE
WHEN-NEW-RECORD-INSTANCE
WHEN-NEW-ITEM-INSTANCE
Form is
available for use
Triggers Fired
WHEN-NEW-ITEM-INSTANCE
WHEN-NEW-RECORD-INSTANCE
WHEN-NEW-ITEM-INSTANCE
Result on User
Screen Display
Insertion point
appears in item
Next record
appears
User Action
User closes
the Forms
Runtime window
Triggers Fired
POST-BLOCK
POST-FORM
Result on User
Screen Display
Forms Runtime
window closes
Practice2
Directing External
Navigation
Form tab
order is
based on
item order in
Object
Navigator
block list
Form
tab
order
GO_ITEM(block_name.item_name);
Do not write colon(:) before the
block name in this commnd.
E.g:
GO_ITEM(emp.sal);
GO_BLOCK(block_name)
GO_FORM(form_name)
5: informative message
10: informative message advising
user of procedural error
20: condition that keeps trigger
from working correctly
25 condition that keeps form from
working correctly
>25: extreme severity
Set :SYSTEM.MESSAGE_LEVEL
variable to a higher level in PREFORM trigger
:SYSTEM.MESSAGE_LEVEL := 25;
Providing User
Feedback in Forms
Message
Alert
Dialog box
Allows user to choose different ways to
proceed
Messages
Syntax:
MESSAGE(message text);
Message
Alerts
Form-level object
Object properties define alert
appearance
Message
Title
Style
icon
Buttons
Form-level trigger
Executes whenever an FRM- or ORAerror occurs
Structure of ON-ERROR
Trigger
BEGIN
--trap FRM errors
IF ERROR_CODE = FRM_error_code1 THEN
error handler;
ELSIF ERROR_CODE = FRM_error_code2 THEN
error handler;
ELSE
--trap ORA errors
IF DBMS_ERROR_CODE = -ORA_error_code1 THEN
error handler
ELSIF DBMS_ERROR_CODE = -ORA_error_code2 THEN
error handler
END IF
END IF;
END;
Code to
trap FRM
errors
Code to
trap
ORA
errors
Form Validation
Data
Database
List of Values
Validation Properties
Cont.
You should use the item level with the
custom forms, and the record or block
level with the data block forms.
The validation properties that are
checked always and before checking
other properties and triggers are:
format mask, required, datatype,
range, and validate from list
Data Type
Minimum Value
Maximum Value
Validate From List
Insert Allowed
Query Allowed
Required
Questio
n
Why do not we use validation properties
instead of validation triggers?
Answer
We use validation triggers for more
complex validations. (like what?)
Validation
Triggers
When Validate Item
Data block
Control block
3.
data_block_field := control_block.text_item
Block order
Canvas order doesnt matter
Controlling Block
Navigation
Canvas
Tab Canvases
Tab canvas
Tab pages
Tab labels
Block order
Stacked Canvases
Stacked
canvas
GO_BLOCK(stacked_canvas_block);
SHOW_VIEW(stacked_canvas);
GO_BLOCK(content_canvas_block);
HIDE_VIEW(stacked_canvas);