在Oracle中重新编译所有无效的存储过程

上一篇 / 下一篇  2008-03-14 14:12:00 / 个人分类:ORA+SQL

在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 
AsStrsql Varchar2(200);BeginFor x In (Select Object_Name 
From All_Objects Where Status = ´INVALID´ 
And Object_Type = ´PROCEDURE´) LoopStrsql := ´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;

最后执行:

exec Zl_Compile_Invalid_Procedure;

如果要看到无法重编译的过程的出错信息,需要执行前设置set serverout on


TAG:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2008-09-05  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 1757
  • 日志数: 49
  • 建立时间: 2007-11-09
  • 更新时间: 2008-04-07

RSS订阅

Open Toolbar