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
Transaction Control The Oracle is transaction oriented; that is, Oracle uses the transactions to make sure the data integrity. The transaction is a sequence of SQL data manip

Error Handling The PL/SQL makes it easy to detect and process the predefined and user-defined error conditions known as exceptions. Whenever an error occurs, an exception is ra

LAWS / RULES - Dollo's Law                     :           Living organisms do exhibit evolutionary irreversibility or evolution is irreversible. Williston's Law

Declaring Records Whenever you define a RECORD type, you may declare records of that type, as the illustration shows: DECLARE TYPE StockItem IS RECORD ( item_no INTEG

Natural Join - SQL In the absence of NATURAL JOIN Example has to be replaced by something rather more longwinded, as shown in Example. Example: Joining IS_CALLED and IS_EN

BETWEEN Operator The operator BETWEEN, tests whether the value lies in a specified series. That means "greater than or equivalent to low value and less than or equivalent to hig

Updating by insertion Syntax : INSERT INTO ENROLMENT VALUES (SID ('S4'), 'Devinder', CID ('C1'));

OUT Mode An OUT parameter returns values to the caller of a subprogram. Within the subprogram, an OUT parameter act like a variable. That means that you can use an OUT formal

Using LIMIT For nested tables, that have no maximum size, the LIMIT returns NULL. For varrays, the LIMIT returns the maximum number of elements that a varray can have (that yo

Question 1 . Compare SQL and PL/SQL Question 2 . Write a database trigger to implement the following check condition                          Given the following table