Chinaunix首页 | 论坛 | 博客
  • 博客访问: 92722068
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类: Oracle

2008-04-21 15:44:01

出处:  
 
阅读提示:本文给出了在Oracle中,重编译所有无效的存储过程的解决办法,供大家参考!

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;

执行

exec Zl_Compile_Invalid_Procedure;

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

阅读(269) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~