set serveroutput on;
spool /tmp/output_del_logs.txt
declare CURSOR cur IS
SELECT a.name
FROM v$asm_alias a, v$asm_file b
where a.group_number = b.group_number
and b.creation_date < sysdate-1
and a.file_number = b.file_number
and b.type='ARCHIVELOG'
and a.name like '%.arc'
order by a.name;
sqlstr VARCHAR2(250);
BEGIN
FOR cur_rec IN cur
LOOP
sqlstr := 'alter diskgroup ASM_BACKUP drop file ''+ASM_BACKUP/DB1/' || cur_rec.name || '''';
DBMS_OUTPUT.PUT_LINE(sqlstr);
EXECUTE IMMEDIATE sqlstr;
END LOOP;
END;
/
spool off;
exit
No comments:
Post a Comment