Advantages of exceptions, PL-SQL Programming

Advantages of Exceptions

Using the exceptions for the error handling has many benefits. Without an exception handling, every time you issue a command, you should ensure for the execution errors:

BEGIN

SELECT ...

-- check for 'no data found' error

SELECT ...

-- check for 'no data found' error

SELECT ...

-- check for 'no data found' error

The Error processing is not clearly separated from general processing; nor is it robust. If you ignore to code a check, the error goes unobserved and is possible to cause other, apparently unrelated errors. With the exceptions, you can handle errors correctly without the requirement to code the multiple checks, which is as shown:

BEGIN

SELECT ...

SELECT ...

SELECT ...

...

EXCEPTION

WHEN NO_DATA_FOUND THEN -- catches all 'no data found' errors

The Exceptions improve readability by letting you isolate the error-handling routines. The primary algorithm is not covered by error recovery algorithms. The Exceptions also improve reliability. You do not need to worry about checking for an error at every point it might occur. An exception handler is just adding to your PL/SQL block. If the exception is still raised in that block or any sub-block, you can be definite it will be handled.

Posted Date: 10/5/2012 5:04:45 AM | Location : United States







Related Discussions:- Advantages of exceptions, Assignment Help, Ask Question on Advantages of exceptions, Get Answer, Expert's Help, Advantages of exceptions Discussions

Write discussion on Advantages of exceptions
Your posts are moderated
Related Questions
Fetching with a Cursor The FETCH statements retrieve the rows in the result set one at a time. After each and every fetch, the cursor advance to the next row in the result set

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

Example of ADD CONSTRAINT in SQL Example: Alternative formulation for MAX_ENROLMENTS ALTER TABLE IS_ENROLLED_ON ADD CONSTRAINT MAX_ENROLMENTS CHECK ((SELECT COUNT (*)

Parameter and Keyword Description: SQL: This SQL is the name of the implicit SQL cursor. %FOUND: This attribute results TRUE if an INSERT, DELETE, or UPDATE state

Some Varray Examples In SQL Plus, assume that you define an object type Project, as described below: SQL> CREATE TYPE Project AS OBJECT ( 2 project_no NUMBER(2), 3 title VARCHA

Project Description: I want a database for large governmental and private data sets on one country that will be easily extended to other countries in the future. Also, the datab

Anatomy of a Command Figure, showing a simple SQL command, is almost identical to its counterpart in the theory book. The only difference arises from the fact that SQL uses a

Relational Algebra - SQL It describes some operators, that together constitute an algebra that is not only relationally complete but also irreducibly so (very nearly- apart f

Use Serially Reusable Packages To help you to manage the use of memory, the PL/SQL gives the pragma SERIALLY_ REUSABLE that mark some packages as serially reusable . So mark

Example of NOT EXISTS in SQL Example: Use of NOT EXISTS CREATE ASSERTION Must_be_enrolled_to_take_exam_alternative1 CHECK ( NOT EXISTS (SELECT StudentId, CourseId