9-5. Raising User-Defined Exceptions Without an Exception Handler

Problem

Your application includes some error handling that is specific to your application. For instance, you want to ensure that the input value for a procedure is in the valid format to be an e-mail address. Rather than writing an exception handler for each user-defined exception, you want to simply raise the exception inline and provide an error number as well.

Solution

This scenario is perfect for using the RAISE_APPLICATION_ERROR procedure. Test the e-mail address that is passed into the procedure to ensure that it follows certain criteria. If it does not contain a specific characteristic of a valid e-mail address, use the RAISE_APPLICATION_ERROR procedure to display an exception ...

Get Oracle and PL/SQL Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.