Search code examples
databaseoracleplsqloracle-sqldeveloperjobs

How to schedule a job in Oracle database to repeat 5 times a day in specific hours


I need to schedule a job in the Oracle database to repeat 5 times a day in specific hours, Usually, I will use SQL developer and schedule the job in repetitive mode but in this case it won't work, also I want to avoid creating 5 jobs in different hours so I wonder if there is a way to do this with just one job, thank you in advance


Solution

  • Create a SCHEDULER JOB:

    BEGIN
      DBMS_SCHEDULER.CREATE_JOB
        (
           job_name        => 'THE_NAME'
          ,start_date      => CURRENT_TIMESTAMP
          ,repeat_interval => 'FREQ=DAILY;INTERVAL=1;BYHOUR=00,04,08,15,18;BYMINUTE=00'
          ,end_date        => NULL
          ,job_class       => 'DEFAULT_JOB_CLASS'
          ,job_type        => 'PLSQL_BLOCK'
          ,job_action      => ...
          ,comments        => ...
        );
    END;