本文介绍了停止在sqlplus脚本中的编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用用@@file
调用的几个sql文件部署pl/sql代码.如果程序包出现编译错误,则脚本会继续执行到最后.
I am deploying pl/sql code using several sql files that are called with @@file
. If a package got a compilation error the script continues to the end.
有没有一种方法可以停止每个编译错误?
Is there a way to stop on every compilation error?
我尝试了WHENEVER SQLERROR EXIT SQL.SQLCODE
,但脚本仍在继续.
I tried WHENEVER SQLERROR EXIT SQL.SQLCODE
but the script still continues.
推荐答案
我不知道本机sql * plus.仅解决方法.像这样:
No native sql*plus way I'm aware of. Only workarounds. Like this:
20:42:50 TEST@oars_sandbox> get scr
1 whenever sqlerror exit rollback
2 create or replace procedure my_failed_proc as
3 i number;
4 begin
5 select 1 into i from me_iz_not_exist;
6 end;
7 /
8 @check my_failed_proc
9 create or replace procedure my_correct_proc as
10 i number;
11 begin
12 select 1 into i from dual;
13 end;
14 /
15* @check my_correct_proc
20:42:57 16 .
20:42:59 TEST@oars_sandbox> get check
1 declare
2 l_status varchar2(100);
3 begin
4 select status into l_status
5 from all_objects where object_name = upper('&1');
6 if l_status = 'INVALID' then
7 raise_application_error(-20000, 'Object &1 is invalid!');
8 end if;
9* end;
20:43:02 10 .
20:43:04 TEST@oars_sandbox> @scr
Warning: Procedure created with compilation errors.
Elapsed: 00:00:00.05
declare
*
ERROR at line 1:
ORA-20000: Object my_failed_proc is invalid!
ORA-06512: at line 8
Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
这篇关于停止在sqlplus脚本中的编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!