Home arrow Oracle arrow Page 4 - Database Interaction with PL/SQL: Pre-defined Exceptions

A Word About OTHERS Exception - Oracle

This is part 6 of a series focusing on database interactions with Oracle PL/SQL. The previous articles discussed several types of collections in PL/SQL. Now Jagadish will look into exception handling using the predefined exceptions available in Oracle PL/SQL.

TABLE OF CONTENTS:
  1. Database Interaction with PL/SQL: Pre-defined Exceptions
  2. No Data Found, Too Many Rows
  3. Dup Val on Index, Zero Divide, Invalid Number, Value Error
  4. A Word About OTHERS Exception
By: Jagadish Chatarji
Rating: starstarstarstarstar / 22
June 28, 2005

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

This is a great exception which can handle almost any type of exception within PL/SQL. In general this exception is used when you are not sure about any specific error which may raise within PL/SQL block. But you are suggested to use this exception caution. This exception is very frequently used for log eventing or auditing. The following example illustrates usage of this exception.

Declare
  v_empno emp.empno%type:=&empno;
  v_ename emp.ename%type:='&ename';
  v_deptno emp.deptno%type:=&deptno;
Begin
  Insert into emp(empno,ename,deptno)
  Values (v_empno,v_ename,v_deptno);
  dbms_output.put_line('Employee Successfully Inserted');
Exception
  When OTHERS then
    dbms_output.put_line('An error occurred. Please check your values');
End ;

You should also observe from the above example that the error message is also bit generic rather than confirming to only one scenario (like previous example). It is suggested to provide a generic error message within OTHERS exception, as you may not know any specific error which may occur.



 
 
>>> More Oracle Articles          >>> More By Jagadish Chatarji
 

blog comments powered by Disqus
   

ORACLE ARTICLES

- Oracle Java Security Woes Continue
- Oracle's New IaaS Cloud Option: There's a Ca...
- Oracle Acquires Eloqua to Boost Cloud Presen...
- Choosing Innovation: Oracle Survey Insights
- Oracle Fixes Privilege Escalation Bug
- Oracle`s Communications Service Availability...
- Oracle Releases Exalytics, Taleo Plans
- Oracle Releases Communications Network Integ...
- Oracle Releases Communications Data Model 11...
- Oracle Releases PeopleSoft PeopleTools 8.52
- Oracle Integrates Cloudera Apache Distro, My...
- Oracle Releases MySQL 5.5.18
- Oracle Announces NoSQL Database Availability
- Sorting Database Columns With the SELECT Sta...
- Retrieving Table Data with the LIKE Operator

Developer Shed Affiliates

 



© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap

Dev Shed Tutorial Topics: