declare
-- Local variables here
i integer :=0;
x varchar2(255) :='hello ';
ex1 exception ;
ex2 exception ;
ex3 exception ;
pragma exception_init(ex1,-20001);
pragma exception_init(ex2,-20002);
begin
dbms_output.enable();
if (i=0) then
--raise ex1;
raise ex3;
raise_application_error(-20002,'hello exception!');
end if;
exception
when ex1 then
x := x || 'exception1';
dbms_output.put_line(x);
when ex2 then
i := SQLCODE;
x := x || 'exception2';
dbms_output.put_line(x || ' SQLCODE:'|| i );
when ex3 then
i := SQLCODE;
x := x || 'exception3';
dbms_output.put_line(x || ' SQLCODE:'|| i );
dbms_output.put_line('异常信息:'||SQLERRM);
dbms_output.put_line('异常行号:'|| DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
when others then
dbms_output.put_line('other exception!');
end;