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
Cursor Variables:   To execute the multi-row query, the Oracle opens an unnamed work region that stores the processing information. You can use an explicit cursor that names

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

Expressions   An expression is a randomly complex combination of the constants, variables, literals, operators, & function calls. The simplest expression is the single variabl

Rollback Behavior When a FORALL statement fails, the database changes are rolled back to an implicit savepoint marked before each of the SQL statement execution. The Changes t

RETURN Statement The RETURN statement instantly completes the execution of a subprogram and returns control to the caller. The Execution then resumes with the statement below t

%TYPE: This attribute gives the datatype of a formerly declared collection, cursor variable, object, field, record, database column, or variable. Datatype: This is simply

Change Sql file into CSV for product registration on Magento Project Description: I have a set of files that are in Sql format and could like for a developer to help me with

Advantages of Subprograms The Subprograms give extensibility; that is, tailor the PL/SQL language to suit your requirements. For illustration, if you require a procedure which

%NOTFOUND The %NOTFOUND is logical, opposite of the %FOUND. The %NOTFOUND yields FALSE if the last fetch returned a row, or TRUE when the final fetch failed to return a row. I

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