PRAGMA EXCEPTION_INIT

简介:

开始

复制代码
set serveroutput on;

DEFINE p_deptno = 10

DECLARE
   e_emps_remaining EXCEPTION;
   
   PRAGMA EXCEPTION_INIT
    (e_emps_remaining, -2292);

BEGIN
   DELETE FROM dept  WHERE deptno = & p_deptno;
   
   COMMIT;

EXCEPTION
   WHEN  e_emps_remaining THEN
      DBMS_OUTPUT.PUT_LINE('Cannot remove dept' || TO_CHAR(&p_deptno) || '. Employees exist. ');

END;
复制代码

运行结果:

anonymous block completed
Cannot remove dept10. Employees exist. 

至于为何,那是因为在 emp 表上有 constraint 存在。

     CONSTRAINT "FK_DEPTNO" FOREIGN KEY ("DEPTNO")
      REFERENCES "SCOTT"."DEPT" ("DEPTNO") ENABLE

 

结束






本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/archive/2012/11/23/2784285.html,如需转载请自行联系原作者

目录
相关文章
|
PHP
Fatal error: Can't use method return value in write context in
说明:   php环境测试会报错下面错误:Fatal error: Can't use method return value in write context in    解决方案:   首先检查自己的php版本,支付宝sdk和demo测试需要php5.5以上版本。
956 12
|
Java Maven Spring
|
2月前
|
安全 搜索推荐 开发者
XYNTService 报错 StartServiceCtrlDispatcher Failed, error code = 1063
【10月更文挑战第7天】XYNTService 报错 StartServiceCtrlDispatcher Failed, error code = 1063
51 6
|
4月前
|
测试技术 C++
【C++】解决googleTest报错error: SEH exception with code 0xc0000005 thrown in the test body.
【C++】解决googleTest报错error: SEH exception with code 0xc0000005 thrown in the test body.
104 1
|
5月前
|
Python
Cannot find reference ‘args‘ in ‘__init__.pyi‘ ,request要写对
Cannot find reference ‘args‘ in ‘__init__.pyi‘ ,request要写对
|
PHP
set_error_handler()
set_error_handler()
49 0
Dart报The return type ‘bool‘ isn‘t a ‘void‘, as required by the closure‘s context
Dart报The return type ‘bool‘ isn‘t a ‘void‘, as required by the closure‘s context
|
Linux
编译OpenJDK8:error: control reaches end of non-void function [-Werror=return-type]
编译OpenJDK8:error: control reaches end of non-void function [-Werror=return-type]
187 0
解决办法:error LNK2005: "void * __cdecl operator new(unsigned int)" 已经在 LIBCMTD.lib(new.obj) 中定义
解决办法:error LNK2005: "void * __cdecl operator new(unsigned int)" 已经在 LIBCMTD.lib(new.obj) 中定义
267 0
|
Java
2022-07-15 17:47:32.079 ERROR 10280 --- [ main] o.s.b.d.LoggingFailureAnalys错误解决方法
2022-07-15 17:47:32.079 ERROR 10280 --- [ main] o.s.b.d.LoggingFailureAnalys错误解决方法
387 0