How to set the repeat interval for a job in Oracle?
In Oracle, you can set the repeat_interval for a job using the following methods:
- Set a fixed time interval for the job to run repeatedly, for example, running every 10 minutes can be specified with the following statement:
- Create a job called ‘job_name’ that repeats every 10 minutes, starting now, and executes a PL/SQL block of code calling ‘your_procedure’, with the job enabled.
- In the above statement, FREQ=MINUTELY indicates a repeating frequency at the minute level, while INTERVAL=10 specifies a time interval of every 10 minutes.
- Using a Cron expression: Cron expression is a standard format used to specify the running cycle of a job. It can be utilized to specify more complex job repetition rules. For example, to run a job every hour between 9 AM to 5 PM daily, the following statement can be used:
- DBMS_SCHEDULER.create_job named ‘job_name’ that repeats daily between 9-17, starts at the current time, runs a PLSQL_BLOCK action of ‘BEGIN your_procedure; END;’, and is enabled.
- In the above statement, FREQ=DAILY indicates a daily repeat frequency, BYHOUR=9-17 specifies running between 9 a.m. and 5 p.m. each day, and BYMINUTE=0 and BYSECOND=0 respectively set the minutes and seconds to 0.
These are just some common settings, you can adjust more complex repeat intervals based on your specific needs. For detailed setting rules, please refer to the official Oracle documentation.