Scheduling jobs using Oracle scheduler

0

Good morning, good afternoon and good evening.

Lords could help me with a problem with dbms_schedule from oracle.

I need to create a JOB that starts every day at 10pm and stops at 4am in the morning, but it has to be run every 1 hour.

But I can not make end_date work, whenever I do the select in the table "USER_SCHEDULE_JOBS" it is as NULL.

Code:

/* Criação da Schedule para o programa */      

BEGIN
  DBMS_SCHEDULER.CREATE_SCHEDULE
  (
    schedule_name => 'a_cada_1_hora_a_partir_das_22',
    start_date => systimestamp + 1/24*22,
    repeat_interval => 'FREQ=HOURLY;INTERVAL=1',
    end_date => systimestamp + 1/24*4,
    comments => 'Executar a cada 1 hora à partir das 19 horas da noite até 22 horas'
  );
END;
/

/* Criação da JOB para rodar o programa de acordo com a SCHEDULE criada */

BEGIN
  DBMS_SCHEDULER.CREATE_JOB
  (
    job_name => 'JOB_TESTE_1',
    program_name => 'INSERT_TBL_JOB_TESTE',
    schedule_name => 'a_cada_1_hora_a_partir_das_22',
    enabled => TRUE,
    auto_drop => FALSE,
    comments => 'Executar o programa INSERT_TBL_JOB_TESTE entre 19hrs até 22hrs.'
   );
END;
/

I could not understand very well what is in the Oracle documentation and I am having trouble scheduling this interval, could you help me?

Thank you in advance.

    
asked by anonymous 05.09.2018 / 01:09

1 answer

0

Well, I did not have any answers to the problem, but I ended up getting the solution here, so it's helpful for anyone who has the same problem:

To set a time range, just use "BYHOUR" and spend the hours, it looks like this:

BEGIN
  DBMS_SCHEDULER.CREATE_SCHEDULE
  (
    schedule_name => 'a_cada_1_hora_a_partir_das_22',
    start_date => systimestamp,
    repeat_interval => 'FREQ=DAILY; BYHOUR=22,23,00,01,02,03,04',
    comments => 'Executar a cada 1 hora à partir das 22 horas da noite até 4 horas da manhã'
  );
END;
/

Thanks ^^

    
05.09.2018 / 20:30