Preliminary study on abnormal treatment of pl/sql

Source: Internet
Author: User
Tags exception handling sql error throw exception

Pl/sql handles exceptions differently from other programming languages, the PL/SQL exception handling mechanism is similar to Ada, with a full inclusion method for handling errors. When an error occurs, the program unconditionally transfers to the exception-handling section, which requires the code to be very clean and separate the error-handling part from the rest of the program. Oracle allows other exception condition types to be declared to extend error/exception handling. This extension makes Pl/sql exception handling very flexible.

When a run-time error occurs, it is called an exception thrown. Pl/sql Program compile-time error is not able to be handled abnormally, only at Run-time the exception can be handled. It is very important to throw and process the exception in Pl/sql programming.

Throw an exception

Throws an exception in three different ways

. Run-time engine via Pl/sql

. Using the Raise statement

. Calling Raise_application_error stored Procedures

When a database or Pl/sql error occurs at run time, an exception is thrown automatically by the Pl/sql runtime engine. Exceptions can also be thrown by raise statements

RAISE Exception_name;

An explicit throw exception is a idiom for programmers to handle declared exceptions, but raise is not limited to declared exceptions, and it can throw any exception. For example, if you want to detect a new Run-time exception handler with a Timeout_on_resource error, you simply use the following statement in your program:

RAISE Timeout_on_resouce;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.