oracle plsql 異常

 
set serveroutput on

DECLARE
pename emp.ename%type;
begin
select ename into pename from emp where ename='1213';
exception
when
no_data_found then     dbms_output.put_line('沒有該數據');
when
others then  dbms_output.put_line('其餘exception');
end;

 

set serveroutput on

DECLARE
pnum number;
begin
pnum:=1/0;
exception
when
zero_divide then     dbms_output.put_line('0不能作除數');
when
others then  dbms_output.put_line('其餘exception');
end;
set serveroutput on

DECLARE
pnum number;
begin
pnum:='abc';
exception
when
value_error then     dbms_output.put_line('value_erroe');
when
others then  dbms_output.put_line('其餘exception');
end;

 

set serveroutput on

DECLARE
pename emp.ename%type;
begin
select ename into pename from emp where deptno=10;
exception
when
too_many_rows then     dbms_output.put_line('查詢語句匹配了多行數據');
when
others then  dbms_output.put_line('其餘exception');
end;
相關文章
相關標籤/搜索