1.一个非常简单的用户自定义异常
declare
a number :='&args';
e exception;
begin
if a=1 then
raise e; --raise 抛出异常
end if;
exception
when e then
dbms_output.put_line('a不能为1');
when others then
dbms_output.put_line('#########');
end;
2.
declare
e exception;
begin
update emp set emp.sal=sal+1000 where deptno='&args';
if sql%notfound then
raise e;
end if;
exception
when e then
dbms_output.put_line('更新语句未执行成功');
end;