Tuesday, 16 February 2016

UNNAMED SYSTEM EXCEPTIONS

                  Those System Exception for which oracle does not provide a name is known as unnamed system exception. These Exception do not occur frequently. These Exceptions have a code and an associated message. These are 2 ways to handle unnamed system exceptions.
1.By using the WHEN OTHERS Exception handler or
2.By associating the Exception Code to a name and using it as a named Exception.
                                 
                  We can assign a name to unnamed System Exceptions using a PRAGMA called EXCEPTION_INIT. EXCEPTION_INIT will associate a predefined oracle error number to a programmer_defined exception name.

STEPS TO BE FOLLOWED TO USE UNNAMED SYSTEM EXCEPTION ARE:
* They are raised Explicitly.
* If they are not hanled in WHEN OTHERS they must be handled Explicitly.
* To handle the Exception Expllicitly, they must be declared using PRAGMA EXCEPTION_INIT as    given above and handled referencing the user_defined exception name in the exception section.

            The General Syntax to declare unnamed System Exception using EXCEPTION_INIT is:
 DECLARE
EXCEPTION_NAME      EXCEPTION;
PRAGMA
EXCEPTION_INIT(exception_name,error_code);
BEGIN
EXECUTION SECTION;
EXCEPTION
WHEN EXCEPTION_NAME THEN
HANDLE THE EXCEPTION;
END;


No comments:

Post a Comment

If you Like my blog Spread it and help friends for whom this blog is useful for their career.