Using exception_init - user-defined exceptions, PL-SQL Programming

Using EXCEPTION_INIT

To handle unnamed internal exceptions, you should use the OTHERS handler or the pragma EXCEPTION_INIT. The pragma is a compiler directive that can be thought of as a parenthetical comment to the compiler. The Pragmas (also known as the pseudoinstructions) are processed at the compile time, not at run time. For illustration, in the language Ada, the pragma below tells the compiler to optimize the use of the storage space:

pragma OPTIMIZE(SPACE);

In the PL/SQL, the pragma EXCEPTION_INIT tells the compiler to relate an exception name with an Oracle error number. This permits you to refer to any internal exception by name & to write a specific handler for it. In the declarative section of a PL/SQL subprogram, block, or package you can code the pragma EXCEPTION_INIT using the syntax as shown:

PRAGMA EXCEPTION_INIT(exception_name, Oracle_error_number);

Where the exception_name is the name of an earlier declared exception. The pragma should appear anywhere after the exception declaration in the similar declarative part, as shown in the illustration below:

DECLARE

deadlock_detected EXCEPTION;

PRAGMA EXCEPTION_INIT(deadlock_detected, -60);

BEGIN

...

EXCEPTION

WHEN deadlock_detected THEN

-- handle the error

END;

Posted Date: 10/5/2012 5:13:29 AM | Location : United States







Related Discussions:- Using exception_init - user-defined exceptions, Assignment Help, Ask Question on Using exception_init - user-defined exceptions, Get Answer, Expert's Help, Using exception_init - user-defined exceptions Discussions

Write discussion on Using exception_init - user-defined exceptions
Your posts are moderated
Related Questions
Character Types The Character types allow you to store alphanumeric data, represent words and text, and manipulate the character strings. CHAR You use the CHAR dataty

Fetching from a Cursor Variable The FETCH statement retrieve rows one at a time from the product set of a multi-row query. The syntax for the same is as shown: FETCH {curso

Row Operators The Row operators return or reference the particular rows. ALL retains the duplicate rows in the result of a query or in an aggregate expression. The DISTINCT el

Difference between 9i & 10G When Oracle releases any new databases then it are having some discrepancy with them. But 10G is having much difference than oracle 9i has. Oracle

THEO R Y OF SPECIAL CREATION - Life originated on the earth due to natural events by the super natural power. The biblical story of creation of world within six days was p

At times, customers make mistakes in submitting their orders and call to cancel the order. Brewbean's wants to create a trigger that automatically updates the stock level of all pr

Predicate - SQL Consider the declarative sentence-a proposition-that is used to introduce this topic:  "Student S1, named Anne, is enrolled on course C1." Recall that th

Project Description: This is stage 1 of a larger conversion project. We are converting a traditional Server/Client application written in Access 2007 into a web interface with S

LEVEL You use the LEVEL with the SELECT CONNECT BY statement to categorize rows from a database table into a tree structure. The LEVEL returns the level number of a node in a

ORIGIN OF EARTH - BIG-BAN G HYPOTHESIS - Origin of life is linked to origin of earth. Cosmos, the Universe originated 10-20 billion years ago by Big Bang (thermonu