您的位置:首页 > 数据库

pl/sql非预定义异常之ORA-02292小例子

2014-03-10 17:53 423 查看
delete from dept where deptno = 10;
delete from dept where deptno = 10
*
ERROR at line 1:
ORA-02292: integrity constraint (SCOTT.FK_DEPTNO) violated - child record found
SQL> declare
  2    e_deptid exception;       --定义异常
  3    pragma exception_init(e_deptid,-2292);       --将异常和错误号关联
  4  begin
  5    delete from dept where deptno = 10;
  6  exception
  7    when e_deptid then         --捕获异常
  8      dbms_output.put_line('There is record at sub table');
  9  end;
 10  /
There is record at sub table
PL/SQL procedure successfully completed.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: