declare
  pre_count number;
  curr_count number;
  retry_count number;
begin

     SYSMAN.MGMT_EMDEP_LOGGER.log_message(P_LOG_LEVEL => SYSMAN.MGMT_EMDEP_LOGGER.G_LOG_LEVEL_INFO, P_COMPONENT_NAME => 'admin_recompile_invalid', P_MESSAGE_ID => 'NZDT_COMPLIANCE_DEBUG_ID#38', P_MESSAGE => 'executing:  ' ||  ' nzdt compile for ' || 'SYSMAN');
     sys.utl_recomp.recomp_parallel(schema => 'SYSMAN');
     retry_count := 1;

    pre_count := 999999999;

    loop
      
    begin
          select count(*) into curr_count from SYS.UTL_RECOMP_INVALID_ALL where status='5';
          exit when curr_count = 0 or curr_count = pre_count;
          sys.utl_recomp.recomp_parallel(schema => 'SYSMAN');
          pre_count := curr_count;
          retry_count := retry_count + 1;
          SYSMAN.MGMT_EMDEP_LOGGER.log_message(P_LOG_LEVEL => SYSMAN.MGMT_EMDEP_LOGGER.G_LOG_LEVEL_INFO, P_COMPONENT_NAME => 'admin_recompile_invalid', P_MESSAGE_ID => 'NZDT_COMPLIANCE_DEBUG_ID#52', P_MESSAGE => 'compile retry count :  ' ||to_char(retry_count) || ' in schema: SYSMAN');
           
  
    exception 
    when others
    then 
             SYSMAN.MGMT_EMDEP_LOGGER.log_message(P_LOG_LEVEL => SYSMAN.MGMT_EMDEP_LOGGER.G_LOG_LEVEL_INFO, P_COMPONENT_NAME => 'admin_recompile_invalid', P_MESSAGE_ID => 'NZDT_COMPLIANCE_DEBUG_ID#58', P_MESSAGE => 'exception in nzdt compilation: ' || SQLCODE||' -ERROR- '||SQLERRM);
    end;

    end loop;
end;
