例外处理:
1)预定义例外:处理常见的oracle错误
2)非预定义例外:处理预定义例外不能处理的例外
3)自定义例外:处理与oracle错误无关的情况
1)预定义例外
case_no_found
cursor_already_open
dup_val_on_index 索引重复添加
invaild_cursor 当试图在不合法的游标上执行操作时,会触发该例外。
invalid_number 当输入的数据有误
no_data_found
too_many_rows
zero_divide 除0错误
value_error 在执行赋值操作时,如果变量的长度不足以容纳实际数据
3)自定义例外
create or replace procedure ex_test(spNo number) is
myex exception;
begin
update emp1 set sal=sal+100 where empno=spNo;
if sql%notfound then
raise myex; --触发myex
end if;
exception when myex then
dbms_output.put_line('没有做任何更新');
end;
/
1)预定义例外:处理常见的oracle错误
2)非预定义例外:处理预定义例外不能处理的例外
3)自定义例外:处理与oracle错误无关的情况
1)预定义例外
case_no_found
cursor_already_open
dup_val_on_index 索引重复添加
invaild_cursor 当试图在不合法的游标上执行操作时,会触发该例外。
invalid_number 当输入的数据有误
no_data_found
too_many_rows
zero_divide 除0错误
value_error 在执行赋值操作时,如果变量的长度不足以容纳实际数据
3)自定义例外
create or replace procedure ex_test(spNo number) is
myex exception;
begin
update emp1 set sal=sal+100 where empno=spNo;
if sql%notfound then
raise myex; --触发myex
end if;
exception when myex then
dbms_output.put_line('没有做任何更新');
end;
/