« Home | Exception Handling in PL/SQL » | Looping in PL/SQL » | Sample cursors in PL/SQL » | SQL Queries » | RandomAccessFiles in Java » | Program to read excel sheet Using Java program » | Redirect output, error report to files instead of ... » | Assertions in java » | Program to copy a folder in java » | java.net.BindException: Address already in use: JV... » 

Tuesday, September 18, 2007 

Exception Handling in PL/SQL-1

DECLARE
v_err_code number;
v_err_text varchar (255);
myexp Exception;
PRAGMA EXCEPTION_INIT(myexp,-2292);
N number:=10;
Y number:=0;
begin
if y=0
then
raise myexp;
else
N:=10/Y;
end if;
Exception
When myexp then
Y:=2;
N:=N/Y;
DBMS_output.put_line('zero divide exception error');
v_err_code:=SQLCODE;
v_err_text:=SQLERRM;
DBMS_output.put_line('value of N is after division is : ' || N);
DBMS_output.put_line('value of Y changed : ' || Y);
DBMS_OUTPUT.PUT_LINE(v_err_code || ' Description is ' ||v_err_text);
end;
/

DECLARE
v_err_code number;
v_err_text varchar (255);
myexp Exception;
PRAGMA EXCEPTION_INIT(myexp,-2292);
N number:=10;
Y number:=0;
begin
if y=0
then
raise myexp;
else
N:=10/Y;
end if;
Exception
When myexp then
RAISE_APPLICATION_ERROR (-20001, 'divide by zero------.');
Y:=2;
N:=N/Y;
DBMS_output.put_line('zero divide exception error');
v_err_code:=SQLCODE;
v_err_text:=SQLERRM;
DBMS_output.put_line('value of N is after division is : ' || N);
DBMS_output.put_line('value of Y changed : ' || Y);
DBMS_OUTPUT.PUT_LINE(v_err_code || ' Description is ' ||v_err_text);
end;

About me

  • I'm phanindra
  • From Hyderabad, Andhra Pradesh, India
  • An Alumini of JNTU Hyd into happening IT industry...
My profile

Visitors
Bloggeries Blog Directory BlogRankings.com singapore blog directory blog search directory
Google
 
Web conceptoftheday.blospot.com