Catch exception in Oracle/plsql--from Cyber

Source: Internet
Author: User

PL/SQL Exception throwing and handling

1. Get Exception Specific information:

1 Dbms_output.put_line (‘Error code is:‘||sqlcode); 2 -- output exception number 3 dbms_output.put_line ( "error message is:  ' 

2. Exception throws

(1) Raise

Declare

Exception_1 exception

Begin

If True Then

Raise exception_1;

End If;

Exception when Exception_1 then

...

End

Or you don't have to throw it yourself.

Declare

Exception_1 exception

pragma exception_init (exception_1,-2292);

Begin

Exception when Exception_1 then

...

End

(2) Raise_application_error

Raise_application_error ( -10020, ' my exception ');

3. Handling of exceptions

exception

When exception 1 Then

When exception 2 Then

...

When others then

End

Catch exception in Oracle/plsql--from cyber

Related Article

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.