oracle plsql exception例外
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了oracle plsql exception例外,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1909字,纯文字阅读大概需要3分钟。
内容图文
系统列外 set serveroutput on declare pename emp.ename%type; begin select ename into pename from emp where empno =1234; exception when no_data_found then dbms_output.put_line(‘没有查到数据‘); when others then dbms_output.put_line(‘其他‘); end; /
too_many_rows例外:
1 --系统例外: too_many_rows 2 3 set serveroutput on 4 declare 5 6 pename emp.ename%type; 7 8 begin 9 10 select ename into pename from emp where deptno = 10; 11 12 exception 13 when too_many_rows then dbms_output.put_line(‘select into 匹配多行‘); 14 when others then dbms_output.put_line(‘其他‘); 15 end; 16 /
算数或转换例外:
1 --系统例外 : value_error 2 3 set serveroutput on 4 5 declare 6 7 pnum number; 8 begin 9 pnum := ‘abc‘; 10 11 exception 12 when value_error then dbms_output.put_line(‘算术或转换错误‘); 13 when others then dbms_output.put_line(‘其他‘); 14 end; 15 /
0不能做除数例外:
1 --系统例外 zero_divide 2 set serveroutput on 3 4 declare 5 6 pnum number; 7 begin 8 9 pnum := 1/0; 10 11 exception 12 when zero_divide then dbms_output.put_line(‘0不能做除数‘); 13 when others then dbms_output.put_line(‘其他‘); 14 end; 15 /
自定义例外:
--自定义例外: set serveroutput on declare cursor cemp is select ename from emp where deptno =50; pename emp.ename%type; --自定义列外 not_emp_data exception; begin open cemp; fetch cemp into pename; if cemp%notfound then raise not_emp_data; end if; --如果程序程序中出现例外,oracle会通过pmon(process monitor)自动关闭清理资源 close cemp; exception when not_emp_data then dbms_output.put_line(‘自定义例外:没有查询到数据‘); when others then dbms_output.put_line(‘其他列外‘); end; /
知识点出处:http://www.imooc.com/learn/360
oracle plsql exception例外
标签:错误 error sel blog any into 多行 cep rac
本文系统来源:http://www.cnblogs.com/xxyfhjl/p/6415775.html
内容总结
以上是互联网集市为您收集整理的oracle plsql exception例外全部内容,希望文章能够帮你解决oracle plsql exception例外所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。