欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

詳解Oracle自定義異常示例

 更新時(shí)間:2016年04月06日 11:20:44   作者:星東爍  
這篇文章主要介紹了詳解Oracle自定義異常示例的相關(guān)資料,需要的朋友可以參考下

1.彈出錯(cuò)誤框:

示例代碼:

declare 
v_count number;
begin 
select count(*) into v_count from dept;
if v_count < 10 then 
raise_application_error(-20001,'數(shù)量小于10');
end if;
end; 

執(zhí)行結(jié)果:

2.控制臺(tái)顯示:

示例代碼:

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('數(shù)量小于10');
when others then 
dbms_output.put_line('其他異常');
end;

執(zhí)行結(jié)果:

PS:ORACLE 用戶(hù)自定義異常小例子

CREATE OR REPLACE PROCEDURE test_Exception_byLeejin
(
ParameterA IN varchar,
ParameterB IN varchar,
ErrorCode OUT varchar --返回值,錯(cuò)誤編碼
)
AS
/*以下是一些變量的定義*/
V NUMBER;
V nvarchar();
V NUMBER; 
APP_EXP EXCEPTION; --自定義異常
BEGIN
ErrorCode :='';
IF (ParameterA=ParameterB) THEN
ErrorCode := 'ParameterA = ParameterB';
RAISE APP_EXP; -- 拋出異常
END IF;
EXCEPTION
WHEN APP_EXP THEN --在處理異常
RAISE_APPLICATION_ERROR(-,ErrorCode);
WHEN OTHERS THEN 
RAISE_APPLICATION_ERROR(-,'未知異常');
END;

相關(guān)文章

最新評(píng)論