Running RMAN commands from PLSQL

I still haven’t been able to determine if this is 100% supported, but it works. If you wanted to delete archived redo logs from within a database session (for some unknown reason), you can run something similar to the following:

1
2
3
4
5
6
7
8
9
BEGIN
  FOR cur IN (SELECT * FROM v$archived_log WHERE deleted = 'NO' AND sequence# < 10) LOOP
    dbms_backup_restore.deletearchivedlog(cur.recid,cur.stamp,cur.name,
                                          cur.thread#,cur.sequence#,
                                          cur.resetlogs_change#,cur.first_change#,
                                          cur.block_size,1);
  END LOOP;
END;
/