Data
Validation
In the
name of Allah, Most Gracious, Most Merciful
Praise
be to Allah, blessing and peace be upon our prophet Mohammed, his family and
his companions. After that,
A
reliable application, relies on data validation methodology. It involves
recognizing the business rules and applying the five types of data validations.
Data Validation Types:
1. Code
validation
2. Data
type validation
3. Data
range validation
4. Constraint
validation
5. Structured
validation
Task Definition:
Let's assume that we have an estimated plan for issuing the total annual quantities of the raw material for production in a factory. Then, the system should check for accurate user input before saving; the estimated total quantity must equal all raw material quantities entered by the user.
If the logical equation violated, then you must prevent the user from saving the data into the database.
Task Solution:
There are two ways to apply a solution for this task:
1- Create WHEN-VALIDATE-RECORD Trigger (block level)
DECLARE
v_total NUMBER
:=0 ;
BEGIN
v_total :=
NVL(:item1,0) + NVL(:item2,0) + NVL(:item3,0) ;
IF tot <> :total THEN
--
Create a message or Alert here
MESSAGE('Quantities Don't Match');
PAUSE;
RAISE FORM_TRIGGER_FAILURE;
END IF;
END;
If the data validation is accurate, it works fine. Otherwise the data condition will be violated and the trigger will fire to Prevent inaccurate data from saving the form.
2- Create PRE-INSERT or
PRE-COMMIT Trigger ( form level)
DECLARE
v_total NUMBER
:=0 ;
BEGIN
v_total :=
NVL(:item1,0) + NVL(:item2,0) + NVL(:item3,0) ;
IF v_total <>
:total THEN
-- Create a message or an alert
here
MESSAGE('Please Check Related
Quantities to FormItem1');
PAUSE;
-- To prevent a user fro saving the violated condition use...
RAISE
FORM_TRIGGER_FAILURE;
END IF;
END;
Learn more about:
·
Hope this helps...
My success only comes from Allah, pls. note your comments and
suggestions are great help for me in progress thanks in advance.