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.

    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;

Oracle Apex validation failed output.

Related Tutorials:

Have you found the answer to your question? If not, you can discuss it with me in the comments section below or join my Q&A community for developers and ask your question. It is FREE.

Vinish Kapoor


Hi, I am a full stack developer and writing about development. I document everything I learn and help thousands of people. 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.

Newest Most Voted
Inline Feedbacks
View all comments
Marc Plumet
Marc Plumet
4 months ago

Good morning,

I have a trivial question as it’s the first time, I’ll use validation.
There are several way to validate user’s data but this is the one I like.

My question is:
Where do you place that PL/SQL function in the page?
On P11_roll_no?
On Create/Page submit?

I ckecked both and I cannot figure out where to add that validation.

Thanks a lot.


3 months ago

Good Afternoon,

my question: I have one field like phone number, the field should required 9 digits how to create validation for this.