Oracle Exception returns complete information ____oracle

Source: Internet
Author: User
Tags chr

--oracle exception return complete information, see finally attached
--Of course, it's best to select the returned information, along with other relevant information about the code
--such as the occurrence of object name, time, etc. insert pre-built reference error table
--11:08 2007-11-26 edit by Inreyou

Declare
StrName Varchar2 (20);
Begin
StrName: = ' datanotfound '; --datanotfound

If StrName = ' Divideiszero ' Then
RAISE Zero_divide;
elsif strName = ' Datanotfound ' Then
RAISE No_data_found;
End If;

exception
When Zero_divide Then
Dbms_output.put_line (' EXCEPTION in Zero_divide ');

When others then
Dbms_output.put_line (' EXCEPTION in others ');
Dbms_output.put_line (CHR) | | | chr (10) | | ' SQLCODE: ');
Dbms_output.put_line (SQLCODE);
Dbms_output.put_line (CHR) | | | chr (10) | | ' SQLERRM: ');
Dbms_output.put_line (SQLERRM);
Dbms_output.put_line (CHR) | | | chr (10) | |
' Dbms_utility. Format_error_stack (complete error message): ');
Dbms_output.put_line (dbms_utility. Format_error_stack);
Dbms_output.put_line (CHR) | | | chr (10) | |
' Dbms_utility. Format_error_backtrace (Stack information of the exception point when an exception occurs): ');
Dbms_output.put_line (dbms_utility. Format_error_backtrace);
Dbms_output.put_line (CHR) | | | chr (10) | |
' Dbms_utility. Format_call_stack (Stack information of the program's current execution point): ');
Dbms_output.put_line (dbms_utility. Format_call_stack);
End

/*
Report:
EXCEPTION in others

SQLCODE:
100

SQLERRM:
ORA-01403: No data found

Dbms_utility. Format_error_stack (full error message):
ORA-01403: No data found


Dbms_utility. Format_error_backtrace (Stack information for exception points when an exception occurs):
ORA-06512: On line 12


Dbms_utility. Format_call_stack (stack information for the current execution point of the program):
-----pl/sql Call Stack-----
  object      line  Object
  handle    number  name
673aab40         46  anonymous block
*/ 

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.