--
connect &DBA/&DBAPASSWORD@&TNSALIAS
--
set serveroutput on
--
declare
 i binary_integer := 0;
 reposConfig xmltype;
 scanComplete boolean := false;
 danglingRef exception;
 PRAGMA EXCEPTION_INIT( danglingRef , -22881 );
 indexOutOfRange exception;
 PRAGMA EXCEPTION_INIT( indexOutOfRange , -31137 );
begin
 while not scanComplete loop
   begin
     dbms_output.put_line('Fetching ' || i);
     reposConfig := dbms_resConfig.getRepositoryResConfig(i);
     i := i+ 1;
   exception
     when danglingRef then
       dbms_output.put_line('Deleting ' || i);
       dbms_resConfig.deleteRepositoryResConfig(i);
     when indexOutOfRange then
       commit;
       scanComplete := true;
   end;
 end loop;
end;
/
disconnect
--

 
