DECLARE
   L_JOB_EXISTS NUMBER;
BEGIN

   FOR C_JOBS IN
      (SELECT JOB
       FROM USER_JOBS
       WHERE WHAT LIKE '%GERA_REANALISE%'
   ) LOOP
      DBMS_JOB.REMOVE(C_JOBS.JOB);
   END LOOP;

   SELECT COUNT(*) INTO L_JOB_EXISTS
   FROM USER_SCHEDULER_JOBS
   WHERE JOB_NAME = 'JOB_GERA_REANALISE';

   IF L_JOB_EXISTS = 1 THEN
       DBMS_SCHEDULER.DROP_JOB(JOB_NAME => 'JOB_GERA_REANALISE');
   END IF;


   DBMS_SCHEDULER.CREATE_JOB (
      job_name           =>  'JOB_GERA_REANALISE',
      job_type           =>  'PLSQL_BLOCK',
      job_action         =>  'BEGIN GERA_REANALISE(); END;',
      start_date         =>  SYSDATE + 1,
      repeat_interval    =>  'FREQ=DAILY; BYHOUR=0; BYMINUTE=0; BYSECOND=0;',
      end_date           =>   NULL,
      auto_drop          =>   FALSE,
      job_class          =>  'DEFAULT_JOB_CLASS',
      ENABLED            =>   TRUE,
      comments           =>  'JOB PARA REANALISE');
   COMMIT;



END;
/