ORACLE pl/sql 系统例外
plsql中有一些系统级例外(exception)简单做一下总结
- no_data_found : insert数据时无对应的数据结果;
- too_many_rows: insert 数据时对某变量赋值多个结果行 ;
- zero_divide : 0位分母;
- value_error:算术或转换错误
- Timeout_on_resource : 等待资源超时
自定义例外:
raise no_data 抛出异常
set serveroutput on
declare
i number;
cursor c1 is select id from table where id = 1;
--自定义例外
no_data exception;
begin
open c1;
fetch c1 into i;
if c1%notfound
then raise no_data;
end if;
--遇到exception执行不到close光标时,oracle会自动调用pmon(process monitor)关闭光标
close c1;
exception
when no_data then dbms_output.put_line('无结果返回');
when others then dbms_output.put_line('others');
end;
/
浙公网安备 33010602011771号