plsql自定义例外

--自定义例外


declare
  cursor  p_scursor is select ename from emp where empno=50;
  p_ename  emp.ename%type;
  --定义自定义的例外
  no_empname_found exception;
begin
  open p_scursor;
     fetch  p_scursor into p_ename;
     if  p_scursor%notfound then
       raise no_empname_found;
     end if;

  close p_scursor;
  exception
    when no_empname_found then dbms_output.put_line('没有此员工号');
    when others  then dbms_output.put_line('其他异常。。。');

end;

猜你喜欢

转载自apple578994358gg.iteye.com/blog/2086295
今日推荐