Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

User defined Exception Handling

sgudipudiNov 9 2011 — edited Nov 10 2011
Hi,

oracle version 11.1.0.7

Question1:
I just want to know what is the difference between the methods for using the user defined exceptions.

Method1 : don't need exception initialization
create or replace procedure p1
as
exc_p1 exception;
begin
 do something .... 
 -- fails
 Raise exc_p1;
 exception when exc_p1 then
 raise;
 end;
 
Method 2: using exception initialization
 create or replace procedure p2
 as
exc_p2 exception;
prgma exception_init(exc_p2,-20999);
begin 
p1;
exception
when exc_p2 then 
raise;
end;
Question2

Please let me know when and where to use these user defined functions and i read Tom kyte's comments on using when others then Raise or raise_application_error
exception handling. Instead of using raise or raise_application_error can i use "dbms_output.put_line(dbms_utility.format_error_backtrace ); dbms_output.put_line(dbms_utility.format_error_stack))" or can i make the exception handler like below
" when others then 
raise_application_error(-20001,'error in p1  '||dbms_utility.format_error_backtrace ||dbms_utility.format_error_stack); " 
Thanks,
Mike
This post has been answered by BluShadow on Nov 10 2011
Jump to Answer

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 8 2011
Added on Nov 9 2011
6 comments
768 views