Orphaned Files in ASM

Hi, In our lab environments we test Data Guard on a daily basis, and we frequently “play” with failover, switchover, and flashback . The output of this playground is that we have some leftovers in the ASM; we call these leftovers orphan files . To solve this, I created SQL to query ASM views against database views. This query should run on the database (not ASM). SET VERIFY OFF SET LINESIZE 200 SET SERVEROUTPUT ON SET PAGESIZE 50000 DECLARE cmd CLOB; BEGIN FOR c IN (SELECT name Diskgroup FROM V$ASM_DISKGROUP) LOOP FOR l IN (SELECT 'rm ' || files files FROM (SELECT '+' || c.Diskgroup || files files, TYPE ...