oracle数据库中的例外处理
2018-01-20 09:33
120 查看
-- 例外 --no_data_found 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 declare pename emp.ename%type; begin select ename into pename from emp where deptno=10; exception when too_many_rows then DBMS_OUTPUT.PUT_LINE('匹配了多行'); when others then dbms_output.put_line('其他例外'); end; --zero_divide declare pnum number; begin pnum:=1/0; exception when zero_divide then dbms_output.put_line('0不能做除数'); when others then dbms_output.put_line('其他例外'); end; --value_error declare pnum number; begin pnum:='asd'; exception when value_error then dbms_output.put_line('算数或转换错误'); when others then dbms_output.put_line('其他例外'); end; --自定义例外 --查询50号部门员工 declare cursor cemp is select ename from emp where deptno=50; pename emp.ename%type; no_emp_found exception; begin open cemp; fetch cemp into pename; if cemp%notfound then rsiae no_emp_found; end if; close cemp; exception when no_emp_found then dbms_output.put_line('没有找到'); when others then dbms_output.put_line('其他'); end;
相关文章推荐
- oracle数据库例外处理与视图
- Oracle笔记:pl/sql例外处理
- 修改oracle数据库表字段类型,处理ORA-01439错误
- 小课堂Week9 例外处理设计的逆袭Part2
- Oracle常用命令10(oracle例外处理)
- oracle数据库用户密码将要过期处理办法(ORA-28002)
- oracle数据库cpu100%处理
- 限制oracle数据库实例中的用户(user)总数 ,11G 大小写/段处理参数
- Oracle数据库常见问题处理
- Oracle数据库中违反唯一约束的处理
- Oracle数据库imp命令导入时1659错误处理
- 安装配置Oracle数据库时的一些处理思路
- Oracle例外处理
- windows计划任务+批处理文件实现oracle数据库的定时备份与恢复
- 巧用例外处理多返回值问题(补充)
- oracle数据库修改主键时子表外键处理
- 如何处理Oracle数据库中的坏块问题
- 在java代码中使用Oracle数据库的事务处理机制
- Oracle数据库中的字符处理技巧总结
- [Web API] 如何让 Web API 统一回传格式以及例外处理[转]