SQL_PLUS中,
spool ExecCompProc.sql
select 'alter procedure '||object_name||' compile;
' From all_objects where status = 'INVALID' and object_type = 'PROCEDURE';
spool off
@ExecCompProc.Sql;
整理成一个存储过程
Create Or Replace Procedure Zl_Compile_Invalid_Procedure As
Strsql Varchar2(200);
Begin
For x In (Select Object_Name From All_Objects Where Status = 'INVALID'
And Object_Type = 'PROCEDURE') Loop
Strsql := 'Alter Procedure ' || x.Object_Name || ' Compile';
Begin
Execute Immediate Strsql;
Exception
--When Others Then Null;
When OTHERS Then dbms_output.put_line(Sqlerrm);
End;
End Loop;
End;
执行
|
如果要看到无法重编译的过程的出错信息,需要执行前设置set serverout on
原文地址:
本文介绍如何使用SQL Plus编写一个存储过程,批量编译数据库中状态为无效的存储过程。通过执行该存储过程,可以一次性解决多个存储过程的编译问题,提高数据库维护效率。
1727

被折叠的 条评论
为什么被折叠?



