Generic Script:
DECLARE
l_stmt VARCHAR2 (2000);
CURSOR c_invalid IS
SELECT *
FROM all_objects
WHERE 1 = 1
AND object_name LIKE 'XX%'
AND STATUS = 'INVALID'
AND OWNER = 'APPS'
--AND OBJECT_TYPE='PACKAGE BODY'
ORDER BY DECODE (OBJECT_TYPE,
'VIEW', 1,
'PACKAGE', 2,
'PACKAGE BODY', 3,
4);
BEGIN
FOR c_rec IN c_invalid
LOOP
BEGIN
IF c_rec.object_type = 'VIEW'
THEN
l_stmt := 'ALTER VIEW ' || c_rec.object_name || ' COMPILE ';
ELSIF c_rec.object_type = 'PACKAGE'
THEN
l_stmt :=
'ALTER PACKAGE ' || c_rec.object_name || ' COMPILE ';
ELSIF c_rec.object_type = 'PACKAGE BODY'
THEN
l_stmt :=
'ALTER PACKAGE ' || c_rec.object_name || ' COMPILE BODY';
ELSE
l_stmt :=
'ALTER ' || c_rec.object_type|| ' ' || c_rec.object_name || ' COMPILE';
END IF;
EXECUTE IMMEDIATE l_stmt;
EXCEPTION
WHEN OTHERS
THEN
NULL;
END;
END LOOP;
END;
/
---------------------------------------------------------
declare
CURSOR c_invalid
is
SELECT object_name
FROM user_objects
WHERE object_NAME LIKE 'OKC\_%' ESCAPE '\'
AND status <> 'VALID'
AND object_type='SYNONYM';
BEGIN
FOR c_rec IN c_invalid
LOOP
BEGIN
EXECUTE IMMEDIATE 'Alter SYNONYM '||c_rec.object_name||' Compile';
exception
WHEN OTHERS THEN
Dbms_Output.put_line(SQLERRM ||' ' ||c_rec.object_name);
END;
END LOOP;
END;
/
declare
CURSOR c_invalid
is
SELECT object_name FROM user_objects
WHERE object_NAME LIKE 'OKC%'
AND status <>'VALID'
AND object_type='VIEW';
BEGIN
FOR c_rec IN c_invalid
LOOP
BEGIN
EXECUTE IMMEDIATE 'Alter VIEW '||c_rec.object_name||' Compile';
exception
WHEN OTHERS THEN
Dbms_Output.put_line(SQLERRM ||' ' ||c_rec.object_name);
END;
END LOOP;
END;
/
declare
CURSOR c_invalid
is
SELECT object_name FROM user_objects
WHERE object_NAME LIKE 'OKC%'
AND status <>'VALID'
AND object_type='PACKAGE';
BEGIN
FOR c_rec IN c_invalid
LOOP
BEGIN
EXECUTE IMMEDIATE 'Alter package '||c_rec.object_name||' Compile';
exception
WHEN OTHERS THEN
Dbms_Output.put_line(SQLERRM ||' ' ||c_rec.object_name);
END;
END LOOP;
END;
/
declare
CURSOR c_invalid
is
SELECT object_name FROM user_objects
WHERE object_NAME LIKE 'OKC%'
AND status <>'VALID'
AND object_type='PACKAGE BODY';
BEGIN
FOR c_rec IN c_invalid
LOOP
BEGIN
EXECUTE IMMEDIATE 'Alter package '||c_rec.object_name||' Compile Body';
exception
WHEN OTHERS THEN
Dbms_Output.put_line(SQLERRM ||' ' ||c_rec.object_name);
END;
END LOOP;
END;
/
No comments:
Post a Comment