1.彈出錯誤框:
示例代碼:
declare
v_count number;
begin
select count(*) into v_count from dept;
if v_count < 10 then
raise_application_error(-20001,'數量小於10');
end if;
end;
執行結果:

2.控制台顯示:
示例代碼:
declare
v_count number;
my_exp exception;
begin
select count(*) into v_count from dept;
if v_count < 10 then
raise my_exp;
end if;
exception
when my_exp then
dbms_output.put_line('數量小於10');
when others then
dbms_output.put_line('其他異常');
end;
執行結果:
