在Oracle中重新編譯所有無效的存儲(chǔ)過程
spool ExecCompProc.sql select 'alter procedure '||object_name||' compile;' From all_objects where status = 'INVALID' and object_type = 'PROCEDURE'; spool off @ExecCompProc.Sql;
整理成一個(gè)存儲(chǔ)過程:
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;
最后執(zhí)行:
exec Zl_Compile_Invalid_Procedure;
如果要看到無法重編譯的過程的出錯(cuò)信息,需要執(zhí)行前設(shè)置set serverout on。
