Error handling in pl/sql, PL-SQL Programming

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 raised. That is, the normal execution stops and control transfers to the exception-handling part of your PL/SQL block or subprogram. To handle the raised exceptions, you write individual routines known as exception handlers.

The Predefined exceptions are raised implicitly by the runtime system. For e.g., when you try to divide a number by zero, the PL/SQL raises the predefined exception ZERO_ DIVIDE automatically. You should raise user-defined exceptions explicitly with the help of the RAISE statement.

You can define the exceptions of your own in the declarative part of any PL/SQL block or subprogram. In the executable part, you ensure for the condition that requires special attention. If you find that the condition exists, then you can execute the RAISE statement. In the example below, you calculate the bonus earned by a salesperson. The bonus depends on the salary and commission. So, if the commission is zero or null, you raise the exception comm_missing.

DECLARE

...

comm_missing EXCEPTION; -- declare exception

BEGIN

...

IF commission IS NULL THEN

RAISE comm_missing; -- raise exception

END IF;

bonus := (salary * 0.10) + (commission * 0.15);

EXCEPTION

WHEN comm_missing THEN ... -- process exception

Posted Date: 10/2/2012 1:53:35 AM | Location : United States







Related Discussions:- Error handling in pl/sql, Assignment Help, Ask Question on Error handling in pl/sql, Get Answer, Expert's Help, Error handling in pl/sql Discussions

Write discussion on Error handling in pl/sql
Your posts are moderated
Related Questions
The SQL ‘CREATE TABLE' scripts for all the tables you have implemented. Note that your tables must correspond exactly to the ERD you have provided in 1. above, or you will lose ma

Project Description: We organize an online system called ACPAS we have created a project called EVO that can be use by our customers to integrate their web sites with the Acpas

Scoping Within the similar scope, all the declared identifiers should be unique. So, even if their datatypes differ, the variables and parameters cannot share the similar name.

First Step at defining type SID in SQL CREATE TYPE SID AS ( C VARCHAR(5) ) ; Explanation: TYPE SID announces that a type named SID is being defined to the syst

Authorize and fetch data from Instagram Project Description: Incorporate Instagram feed on mobile site platform: c#, ms sql, jquerymobile, jquery Web admin Author

What is Cursors how to use it in Real time application ?

Effects of NULL in Aggregate Operator - SQL Let aggop(x) be an invocation of some aggregate operator aggop in SQL, where x is an expression (usually an open expression) to be

Left and Right Joins LEFT OUTER JOIN can be used when you want to retrieve the data from the main table (table1) even if there is no match in other tables (table_2, table_3...

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

Using FIRST and LAST FIRST and LAST return the first and last (minimum and maximum) index numbers in a collection. When the collection is empty, the FIRST and LAST return NULL