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;

 

相关文章:

  • 2021-08-02
  • 2022-12-23
  • 2022-12-23
  • 2021-07-26
  • 2021-07-17
  • 2021-09-10
  • 2021-12-30
  • 2022-12-23
猜你喜欢
  • 2021-10-17
  • 2021-07-03
  • 2021-05-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案