Oracle存储过程中自定义异常
作者:网络转载 发布时间:[ 2017/2/20 10:56:06 ] 推荐标签:数据库 Oracle
ORACLE 用户自定义异常小例子
1.进入pl/sql测试窗口
2.执行语句
declare
empname varchar2(255);
customize_exp EXCEPTION; --自定义异常
begin
FOR c IN (select d.* from scott.dept d) LOOP
begin
dbms_output.put_line('dept: ' || c.deptno || '=' || c.dname);
--当部门ID为40时抛出异常
if (c.deptno = 40) then
RAISE customize_exp; -- 抛出自定义异常
end if;
--当部门ID为10、20、30时,会执行下面的查询,由于出现多行所以会报 Too many rows round!
--当部门ID为40时,这里不再执行,控制转向
select e.ename into empname from scott.emp e
where e.deptno = c.deptno;
exception
when customize_exp then
dbms_output.put_line('customize error!');
when no_data_found then
dbms_output.put_line('Data is not found!');
when too_many_rows then
dbms_output.put_line('Too many rows round!');
when OTHERS then
dbms_output.put_line('others error');
end;
END LOOP;
end;
3.结果
相关推荐
更新发布
常用的选择回归测试的方式有哪些?
2022/6/14 16:14:27测试流程中需要重点把关几个过程?
2021/10/18 15:37:44性能测试的七种方法
2021/9/17 15:19:29全链路压测优化思路
2021/9/14 15:42:25性能测试流程浅谈
2021/5/28 17:25:47常见的APP性能测试指标
2021/5/8 17:01:11系统性能测试及调优前期准备
2021/4/15 14:41:29国内比较好用的5款测试管理工具
2021/3/25 17:23:31