oracle – 我可以在函数编译失败时使SQL * Plus退出并出现错误吗
发布时间:2021-01-20 23:30:35 所属栏目:站长百科 来源:网络整理
导读:我一直致力于通过SQL * Plus以自动方式部署的Oracle功能.有时我犯了一个错误,Oracle说: Warning: Function created with compilation errors. 然后我可以使用SHOW ERR来查看错误,但我想知道是否有一些我可以设置的配置,在这样的编译错误上: 将不会创建该功
我一直致力于通过SQL * Plus以自动方式部署的Oracle功能.有时我犯了一个错误,Oracle说:
然后我可以使用SHOW ERR来查看错误,但我想知道是否有一些我可以设置的配置,在这样的编译错误上: >将不会创建该功能 像 解决方法这有点令人费解,但你可以.初始CREATE FUNCTION或CREATE PROCEDURE语句将创建函数或过程.您必须在脚本中检测到存在错误,并在出现错误时显式删除函数和/或过程.但是你必须在删除对象之前捕获错误.这将需要在CREATE语句之后的脚本中的一些代码. whenever sqlerror exit failure; create or replace procedure compile_error as begin select count(*) into no_such_variable from emp; end; / show error; declare l_num_errors integer; begin select count(*) into l_num_errors from user_errors where name = 'COMPILE_ERROR'; if( l_num_errors > 0 ) then execute immediate 'DROP PROCEDURE compile_error'; raise_application_error( -20001,'Errors in COMPILE_ERROR' ); end if; end; / 执行时,此脚本将生成以下输出,其中包含错误并将删除该过程. SQL> @c:tempcompile_errors.sql Warning: Procedure created with compilation errors. Errors for PROCEDURE COMPILE_ERROR: LINE/COL ERROR -------- ----------------------------------------------------------------- 4/3 PL/SQL: SQL Statement ignored 5/10 PLS-00201: identifier 'NO_SUCH_VARIABLE' must be declared 6/5 PL/SQL: ORA-00904: : invalid identifier declare * ERROR at line 1: ORA-20001: Errors in COMPILE_ERROR ORA-06512: at line 12 Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning,OLAP,Data Mining and Real Application Testing options (编辑:威海站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
站长推荐
热点阅读