您的位置:首页 > 数据库 > Oracle

oracle自定义异常

2016-04-06 09:32 627 查看
1.弹出错误框:

示例代码:

declare
v_count number;
begin
select count(*) into v_count from dept;
if v_count < 10 then
raise_application_error(-20001,'数量小于10');
end if;
end;


执行结果:



2.控制台显示:

示例代码:

declare
v_count number;
my_exp exception;
begin
select count(*) into v_count from dept;
if v_count < 10 then
raise my_exp;
end if;
exception
when my_exp then
dbms_output.put_line('数量小于10');
when others then
dbms_output.put_line('其他异常');
end;


执行结果:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: