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.
pl/sql非预定义异常之ORA-02292小例子
最新推荐文章于 2021-04-05 14:04:49 发布