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
IS NULL Operator The IS NULL operator returns the Boolean value TRUE whenever its operand is null or FALSE if it is not null. The comparisons including the nulls always yield NU

%NOTFOUND The %NOTFOUND is the logical opposite of the %FOUND. The %NOTFOUND yields TRUE when an INSERT, UPDATE, or DELETE statement affected no rows, or the SELECT INTO state

Explicit Cursors The set of rows returned by the query can include zero, one, or multiple rows, depending on how many rows meet your search criteria. Whenever a query returns

Recursive Subprograms The recursive subprogram is the one that calls itself. Think of a recursive call as a call to a few other subprograms that does the similar task as your

Lightweight system to provide and take info from workers in the field and office, have basic design outlined already just require build and implementation Desired Skills CSS,

I need SQL to infopath data connection Project Description: Want data retrieval connection from SQL to SharePoint infopath Skills required are Sharepoint, SQL

Using ROLLBACK The ROLLBACK statements end the present transaction and undo any change made during the transaction. The Rolling back is helpful for two reasons. Firstly, if yo

Implicit Cursors The Oracle implicitly opens a cursor to process each SQL statement not related with an explicitly declared cursor. The PL/SQL lets you refer to the most recen

Recursion The Recursion is a powerful method for simplify the design of the algorithms. Principally, the recursion means the self-reference. In the recursive mathematical serie

MILLER-UREY' S EXPERIMENTAL PROCEDURES - They recreated the probable conditions on the primitive earth in the laboratory. An atmosphere containing hydrogen, ammonia, me