In Oracle PL/SQL I need to write a stored procedure that may throw a custom exception and this exception must be caught (only this one) from some anonymous procedure calling this stored procedure. How to achieve that?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Custom exceptions (more often called “user defined exceptions”) are easy enough to declare:
The main thing is that if you want to throw the specific exception in one procedure and catch in another you must declare the exception somewhere which is in scope for both programs. As you specify the calling (catching) procedure is an anonymous PL/SQL block that means you must declare the exception in a package spec: this can be the package which holds the called procedure or a package spec especially created to hold user-defined exceptions.
The PL/SQL documentation covers exceptions in some depth. Find out more.