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


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:


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:


deadlock_detected EXCEPTION;

PRAGMA EXCEPTION_INIT(deadlock_detected, -60);




WHEN deadlock_detected THEN

-- handle the error


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
Special cases of projection This section describes the identity projection, r {ALL BUT}, and the projection on no attributes, r { }, which yields TABLE_DUM when r is empty, ot

Use of COUNT in SQL It describes and discusses various general methods of expressing constraints, eventually noting that support for "=" with relation operands is sufficient f

SQL Cursor   The Oracle implicitly opens a cursor to process each SQL statement not related with an explicit cursor. The PL/SQL refers to the most current implicit cursor as t

Indeterminacy in SQL Some SQL expressions are actually not function invocations at all in the mathematical sense, being indeterminate-invocations operating on identical input

Procedural Constraint Enforcement (Triggers) SQL has an alternative method of addressing database integrity, involving event-driven procedural code. The special procedures th

ROWID The ROWID returns the rowid (binary address) of a row in the database table. You can use the variables of the type UROWID to store rowids in a readable format. In the il

Example of GROUP BY and COLLECT Operator Example: Using GROUP BY and COLLECT to obtain C_ER2 SELECT CourseId, CAST ( COLLECT (ROW (StudentId, Mark)) AS ROW (Studen

Built-In Functions The PL/SQL provides a lot of powerful functions to help you to manipulate the data. These built-in functions fall into the categories as shown below: error r

Effects of NULL for Multiple Assignments - SQL If the row expression given as the source for a multiple assignment evaluates to NULL, then NULL is assigned to each target. If

Renaming Columns - SQL SQL has no direct counterpart of RENAME. To derive the table on the right in Figure 4.4 from the table on the left, Tutorial D has IS_CALLED RENAME ( St