Monday, October 13, 2008

Oracle SQL predefined exceptions

If you've written PL/SQL stored procedures and functions, you may have use BEGIN/END blocks with EXCEPTION. Basically, this is kind of like try/catch in Java, and you can catch different exceptions and handle them. The syntax is like this:

BEGIN
-- your code goes here. If there isn't any, put NULL;
NULL;
EXCEPTION
WHEN NO_DATA_FOUND OR BLAHBLAH THEN
...
WHEN OTHERS THEN
END;


To get a list of the constants ("predefined exceptions") that you can catch, look here.

No comments:

Labels

Blog Archive

Contributors