Wednesday, 17 February 2016

USER DEFINED EXCEPTIONS

         Apart from sytsem exceptions we can explicitly define exceptions based on business rules.These are known as user defined exceptions.
*They should be explicitly declared in the declaration section.
*They should be explicitly raised in the execution section,
*They should be handled by referencing the user defined exception name in the exception section.

Example:

Declare
praveen Exception;
a number:=&a;
begin
if(a>0) then
dbms_output.put_line('a is positive');
else
if(a=0) then
raise praveen;
else 
dbms_output.put_line('a is negative');
end if;
end if;
Exception
when praveen then
dbms_output.put_line('a is neutral');
end;

No comments:

Post a Comment

If you Like my blog Spread it and help friends for whom this blog is useful for their career.