DECLARE
   CURSOR Invalid_Objects_Cur IS
      SELECT Object_Name, Object_Type, Last_Ddl_Time, Status,
             DECODE (LTRIM(RTRIM(Object_Type)),
                'PACKAGE',4,'PROCEDURE',3,'FUNCTION',2,'VIEW',1) indx_var
      FROM   User_Objects
      WHERE  Object_type IN ('PACKAGE','PACKAGE BODY', 'FUNCTION','VIEW')
      ORDER BY Indx_Var;

V_Compile_Statement VARCHAR2(500);

BEGIN
   FOR Invalid_Objects_Rec in Invalid_Objects_Cur LOOP
      V_Compile_Statement := 'DROP ' || Invalid_Objects_Rec.Object_Type || ' "' || Invalid_Objects_Rec.Object_Name || '"';
      EXECUTE IMMEDIATE V_Compile_Statement;
   END LOOP;
END;

