Oracle
  Home arrow Oracle arrow Database Interaction with PL/SQL: Pre-...
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM Developerworks
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ORACLE

Database Interaction with PL/SQL: Pre-defined Exceptions
By: Jagadish Chatarji
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 16
    2005-06-28

    Table of Contents:
  • Database Interaction with PL/SQL: Pre-defined Exceptions
  • No Data Found, Too Many Rows
  • Dup Val on Index, Zero Divide, Invalid Number, Value Error
  • A Word About OTHERS Exception

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Virtual Tradeshows by Ziff Davis Enterprise – A Unique Opportunity to Interact with IT Experts, Access Information, and Gain Insight on Today’s Trends in Technology Learn more

    Database Interaction with PL/SQL: Pre-defined Exceptions
    (Page 1 of 4 )

    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.

    Please note that all the examples in this series have been tested only with Oracle 10g and not with all the previous versions of Oracle. Refer to the documentation of the respective version you are using if any programs fail to execute.

    Introduction to Exception Handling

    Before going to exception handling, let us first determine all the possible ways to get errors. Errors may occur in PL/SQL (of course, not only PL/SQL) in several possible ways including hardware failures, network failures, bugs in programs, out of memory and several other reasons. We may not know which error has been raised at what moment. But we need to handle all such errors and provide some meaningful messages to the user (instead of making the user horrified with jargon-filled error messages).

    An exception is generally a runtime error which gets raised by PL/SQL runtime when a PL/SQL block is in the process of execution. Handling the exception consists of trapping the error (or exception) and providing a meaningful explanation to the user without showing the weird error message raised by the PL/SQL run-time. This doesn't mean only providing meaningful explanations; we can take certain actions (programmatically) when an error occurs at runtime.

    Basically, there exist two types of exceptions:

    1. Predefined Exceptions

      Predefined exceptions are the ones which are already defined by Oracle team that correspond to the most common oracle errors (like division by zero, out of memory, etc.). We can handle them directly within our program without declaring them, and we have thousands of such type of exceptions. In this article, I cover the most important ones.

    2. User-Defined Exceptions

      User-Defined Exceptions must be declared and raised explicitly by the user (by issuing RAISE statements). These exceptions are created, used, raised and implemented by user himself. Oracle will not know about any of those exceptions (till it finds the declarations of those exceptions within the PL/SQL block). There exists EXCEPTION section within the PL/SQL block to handle any sort of exceptions and the section is optional. Let us start by looking into some of the most commonly used predefined exceptions.

    More Oracle Articles
    More By Jagadish Chatarji


       · Hello guys, this is my article on working with pre-defined exceptions in PL/SQL. You...
     

       

    ORACLE ARTICLES

    - Tuning PL/SQL Code
    - Debugging PL/SQL Code
    - Testing PL/SQL Code
    - Working With PL/SQL Code
    - Conditional Compilation for Oracle Database ...
    - Compile-Time Warnings for Oracle DB 10g
    - Compiling PL/SQL Code for an Oracle Database
    - Troubleshooting PL/SQL Code
    - Managing PL/SQL Code
    - Data Manipulation and More for HTML DB Appli...
    - Oracle Database Fundamentals
    - Adding Processes to HTML DB Applications
    - Adding Computations, Processes, and Validati...
    - Sub-templates and More with Oracle HTML DB
    - Focusing on Templates in Oracle HTML DB

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway