Fires during the Validate the Record process. Specifically, it fires as the last part of record validation for records with the New or Changed validation status.
Definition Level form or block
SELECT statements, unrestricted Built-ins
Enter Query Mode no
Use a When-Validate-Record trigger to supplement Oracle Forms default record validation processing.
Note that it is possible to write a When-Validate-Record trigger that changes the value of an item in the record that Oracle Forms is validating. If validation succeeds, Oracle Forms marks the record and all of the fields as Valid and does not re-validate. While this behavior is necessary to avoid validation loops, it does make it possible for your application to commit an invalid value to the database.
If fired as part of validation initiated by navigation, navigation fails, and the focus remains on the original item.
Validate the Record
The following example verifies that Start_Date is less than End_Date. Since these two text items have values that are related, it's more convenient to check the combination of them once at the record level, rather than check each item separately. This code presumes both date items are mandatory and that neither will be NULL.
/* Method 1: Hardcode the item names into the trigger.
** Structured this way, the chance this code will
** be reusable in other forms we write is pretty
** low because of dependency on block and item
** names.
*/
BEGIN
IF :Experiment.Start_Date > :Experiment.End_Date THEN
Message('Your date range ends before it starts!');
RAISE Form_Trigger_Failure;
END IF;
END;
/* Method 2: Call a generic procedure to check the date
** range. This way our date check can be used in
** any validation trigger where we want to check
** that a starting date in a range comes before
** the ending date. Another bonus is that with the
** error message in one standard place, i.e. the
** procedure, the user will always get a
** consistent failure message, regardless of the
** form they're currently in.
*/
BEGIN
Check_Date_Range(:Experiment.Start_Date,:Experiment.End_Date);
END;
/*
** The procedure looks like this
*/
PROCEDURE Check_Date_Range( d1 DATE, d2 DATE ) IS
BEGIN
IF d1 > d2 THEN
Message('Your date range ends before it starts!');
RAISE Form_Trigger_Failure;
END IF;
END;