当前位置:Gxlcms > 数据库问题 > oracle中的预定异常和自定义异常

oracle中的预定异常和自定义异常

时间:2021-07-01 10:21:17 帮助过:2人阅读

异常 declare v_comm emp.comm%type; e_comm_is_null exception; --定义异常类型变量 begin select comm into v_comm from emp where empno=7788; if v_comm is null then raise e_comm_is_null; end if; exception when no_data_found then dbms_output.put_line(雇员不存在!错误为:||SQLcode||SQLErrm); when e_comm_is_null then dbms_output.put_line(该雇员无补助); end;

结果:技术分享图片

用户自定义异常

--自定义异常
declare
   v_comm emp.comm%type;
begin
   select comm into v_comm from emp where empno=7788;
   if v_comm is null then
      raise_application_error(-20010,该雇员无补助);
   end if;
end;

结果:技术分享图片

 注意自定义异常的编号范围是 -20999-20000之间的负整数,消息长度最长为2048字节

 

oracle中的预定异常和自定义异常

标签:int   数据库   pad   bms   cell   输入   分享图片   rac   大小   

人气教程排行