现在的位置: 首页 > 综合 > 正文

oracle自定义异常

2013年01月01日 ⁄ 综合 ⁄ 共 372字 ⁄ 字号 评论关闭

自定义异常必须使用raise关键字

例如
DECLARE
tt varchar2(100);
e exception;
begin
select cagentname into tt from tagent where cagentid='236';
if tt<>'aaaa' then
raise e;
end if;
Exception
when e then
DBMS_OUTPUT.PUT_LINE('NO equal aaaa');
end;

如果是系统异常不需要使用raise
declare 
  tt varchar2(100);
begin
   select cagentname into tt from tagent where cagentid='999999';
end;
Exception
when no_data_dound then
   DBMS_OUTPUT.PUT_LINE('NO DATA');
end;

抱歉!评论已关闭.