Press "Enter" to skip to content

Oracle Apex Validation: PL/SQL Function Returning Error Text

In Oracle Apex, there are several types of validation that you can use to validate an item. But if the validation requires to check multiple conditions and need to display the relevant error messages, then you should choose the PL/SQL Function (returning error text) type of validation. Because using this type, you can show the relevant error messages easily.

PL/SQL Function (returning error text) Example

This validation type aborts the page submit if the PL/SQL function returning text message and shows that text as an error message, and if it is not returning any text, then it means the validation is successful.

The following PL/SQL function example will validate the student’s roll number, that it should start with the letter ‘S’ and should have seven-character length.

If any of the conditions will not match, then it will give the appropriate error message.

Begin
    If substr(:p11_roll_no, 1, 1) != 'S' Then
        return('Roll number must start with S.');
    Elsif length(:p11_roll_no) < 7 Then
        return('Roll number must be 7 character long.');
    End If;
End;

Oracle Apex validation failed output.

Related Tutorials:

Vinish Kapoor

Hi, I am a full stack developer and writing about development. I document everything I learn and help thousands of people. foxinfotech.in is created, written, and maintained by me; it is built on WordPress, and hosted by Bluehost. Connect with me on Facebook, Twitter, GitHub, and get notifications for new posts.

Comments are closed.