DECLARE
-------------------------------------------------------------------
-- CURSOR PARA OBTER AS PROCEDURES, FUNÇÕES E PACKAGES INVÁLIDAS
-------------------------------------------------------------------
CURSOR c_obj IS
SELECT DISTINCT u.object_name,
-- decode(u.object_type,'PACKAGE BODY','PACKAGE',u.object_type) object_type,
object_type, u.created
FROM user_objects u
WHERE u.status = 'INVALID'
AND u.object_type IN ('PROCEDURE','FUNCTION','PACKAGE BODY','PACKAGE')
ORDER BY u.created;
-------------------------------------------------------------------
-- CURSOR PARA OBTER AS PROCEDURES, FUNÇÕES E PACKAGES INVÁLIDAS
-------------------------------------------------------------------
CURSOR c_obj IS
SELECT DISTINCT u.object_name,
-- decode(u.object_type,'PACKAGE BODY','PACKAGE',u.object_type) object_type,
object_type, u.created
FROM user_objects u
WHERE u.status = 'INVALID'
AND u.object_type IN ('PROCEDURE','FUNCTION','PACKAGE BODY','PACKAGE')
ORDER BY u.created;
-------------------------------------------------------------------
-- CURSOR PARA OBTER AS PACKAGES BODYS INVÁLIDAS
-------------------------------------------------------------------
CURSOR c_obj_body IS
SELECT DISTINCT u.object_name,
object_type, u.created
FROM user_objects u
WHERE u..status = 'INVALID'
AND u.object_type IN ('PACKAGE BODYS')
ORDER BY u.created;
-- CURSOR PARA OBTER AS PACKAGES BODYS INVÁLIDAS
-------------------------------------------------------------------
CURSOR c_obj_body IS
SELECT DISTINCT u.object_name,
object_type, u.created
FROM user_objects u
WHERE u..status = 'INVALID'
AND u.object_type IN ('PACKAGE BODYS')
ORDER BY u.created;
r_obj NUMBER;
r_obj_body NUMBER;
BEGIN
FOR r_obj IN c_obj LOOP
BEGIN
EXECUTE IMMEDIATE 'alter '||r_obj.object_type||' '||r_obj.object_name||' compile';
dbms_output.put_line(r_obj.object_type||' '||r_obj.object_name||': COMPILADO!' );
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Erro Compilando '||r_obj.object_type||' '||r_obj.object_name);
END;
END LOOP;
END;
-------------------------------------------------------------------
r_obj_body NUMBER;
BEGIN
FOR r_obj IN c_obj LOOP
BEGIN
EXECUTE IMMEDIATE 'alter '||r_obj.object_type||' '||r_obj.object_name||' compile';
dbms_output.put_line(r_obj.object_type||' '||r_obj.object_name||': COMPILADO!' );
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Erro Compilando '||r_obj.object_type||' '||r_obj.object_name);
END;
END LOOP;
END;
-------------------------------------------------------------------
-- Exemplo sem o Cursor
-------------------------------------------------------------------
SELECT 'ALTER '|| OBJECT_TYPE || ' ' || OBJECT_NAME || ' COMPILE; '
FROM USER_OBJECTS
WHERE OBJECT_TYPE IN ('PROCEDURE','FUNCTION','PACKAGE')
AND STATUS = 'INVALID'
-------------------------------------------------------------------
-------------------------------------------------------------------
SELECT 'ALTER '|| OBJECT_TYPE || ' ' || OBJECT_NAME || ' COMPILE; '
FROM USER_OBJECTS
WHERE OBJECT_TYPE IN ('PROCEDURE','FUNCTION','PACKAGE')
AND STATUS = 'INVALID'
-------------------------------------------------------------------
SELECT 'ALTER PACKAGE ' || OBJECT_NAME || ' COMPILE BODY; '
FROM USER_OBJECTS
WHERE OBJECT_TYPE IN ('PACKAGE BODY')
AND STATUS = 'INVALID'
DROP PROCEDURE itf_ato_sap_cor_UF
FROM USER_OBJECTS
WHERE OBJECT_TYPE IN ('PACKAGE BODY')
AND STATUS = 'INVALID'
DROP PROCEDURE itf_ato_sap_cor_UF
0 comentários:
Postar um comentário