- 処理内容:スキーマ内のコンパイルエラーになったパッケージの再コンパイルを行う
declare
C_SCHEMA costant varchar2(10) := 'ORCL';
W_SQL varchar2(1000);
W_CNT pls_integer := 0;
W_ERR_CNT pls_integer := 0;
cursor CUR1 is
select 'alter PACKAGE ' || OBJECT_NAME || ' compile'
from dba_objects
where OWNER = C_SCHEMA
and OBJECT_TYPE = 'PACKAGE BODY'
and STATUS = 'INVALID';
begin
open CUR1
loop
fetch CUR1 into W_SQL;
exit when CUR1%notfound;
begin
W_CNT := W_CNT + 1;
execute immediate W_SQL;
dbms_output.put_line(W_SQL || ' -> COMPILE SUCCESS');
exception
when others then
W_ERR_CNT := W_ERR_CNT + 1;
dbms_output.put_line(W_SQL || ' -> COMPILE FAILED');
end;
end loop;
close CUR1;
dbms_output.put_line('処理件数 = ' || W_CNT);
dbms_output.put_line('失敗件数 = ' || W_ERR_CNT);
exception
when others then
close CUR1;
end;