查询编译不通过的存储过程并重新编译

declare

cursor proce is Select Object_Name,owner,object_type From All_Objects Where Status = 'INVANID' and 
(Object_type = 'PROCEDURE' or lower(Object_type) = 'function');

Strsql Varchar2(200);

BEGIN    
    for i in proce loop
        Strsql:= 'Alter '||i.object_type||' '||i.owner||'.'||i.Object_name||' Compile';
        Begin
            Excute Immediate Strsql;
            Exception
            -- When others then Null;
            when others THEN
            dbms_output.put_line(i.owner||'.'||i.Object_name||'---'||Sqlerrm);
        end;
    end loop;
END;
原文地址:https://www.cnblogs.com/yahutiaotiao/p/8030451.html