Friday 27 December 2013

A sample validation in APEX 4.2



We can create validations in APEX which is similar to WHEN-VALIDATE-RECORD trigger in Oracle forms. The following example explains it briefly.

A Form on a Table with Report is already created based on the table EMP as shown in the following screenshot.

Report:


Form:



A record can be updated by clicking on edit link in report. We are going to create a validation like any employee with department number 10 should not be allowed to update.

Click on Edit Page in Form. Then we will be taken to following screen.


In the Page Rendering section, right click on validations and click create.



Choose validation level as Page in the following screen.



Give the validation name in following screen.


Select validation type as SQL in following screen.





Select the type of validation we want to create as NOT Exists. Now the validation will check for any record before saving whether it has the department number as 10. If the employee belongs to department 10 then it will throw error as ‘Update not allowed’.


 
Choose the Save button from the When Button Pressed list. It will ensure that any record which got updated will be validated before saving.



Click on Create Validation to finally create the validation. Validation will be created as shown below.


An instance of how the error will fire when trying to update a record with employee number 10 is shown in the following screenshot.

No comments:

Post a Comment