Oracle Scheduler: Calendaring

Oracle Scheduler: Calendaring Syntax

|-----------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| freq=daily | Run once per day |
| freq=daily;bymonthday=2 | Run once on each 2nd day of a month |
| freq=daily;bymonthday=-1 | Run on the last day of a month |
| freq=daily;byday=tue | Run on Tuesdays. For a strange reason, the given value freq= is irrelevant: freq=monthly;byday=tue or freq=minutely;byday=tue etc. produce the same calendar! |
| freq=daily;byday=tue; byhour=12; byminute=0; bysecond=0 | Run on tuesdays almost exactly at noon (the fraction of a second cannot be specified). |
| freq=monthly;byday=2tue | Run on each month's second tuesday |
| freq=minutely;interval=5 | Run every fifth minute. |
| freq=hourly;byminute=7,31,42 | Runs three times per hour: on each hour's 7th, 31st and 42nd minute. |
| freq=minutely;byhour=7,8,16,17 | Runs every minute, but only between 7:00 and 9:00, and between 16:00 and 18:00. |
| freq=monthly;byday=mon,tue,wed,thu,fri;bysetpos=1 | Runs on each month's first business day. |
| freq=monthly;byday=mon,tue,wed,thu,fri;bysetpos=-1 | Runs on each month's last business day. |
| freq=daily;byday=mon,tue,wed,thu,fri;exclude=holidays | Run daily, Monday through Friday, but exclude days referenced in the schedule named holidays. |

Testing calendar strings

The following procedure can be used to test a calendar string

复制代码
create or replace procedure tq84_test_calendaring_syntax (
   calendar_string varchar2,
   start_date      timestamp with time zone := systimestamp,
   n               integer                  := 10
)
   authid definer
as
   next_run_date   timestamp with time zone := start_date;
begin

   for i in 1 .. n loop

      dbms_scheduler.evaluate_calendar_string(
         calendar_string   => calendar_string,
         start_date        => start_date,
         return_date_after => next_run_date,
         next_run_date     => next_run_date
     );

     dbms_output.put_line(next_run_date);

   end loop; 
end tq84_test_calendaring_syntax;
/

Time zone

The value of the scheduler's default time zone is important when using the calendaring syntax. This value can be queried like so:

复制代码
select
   value
from
   dba_scheduler_global_attribute
where
   attribute_name = 'DEFALT_TIMEZONE'
;

The value can be set with dbms_scheduler.set_scheduler_attribute.

相关推荐
库库的数据库笔记21 小时前
金融核心交易系统的数据库国产信创改造该如何做?
大数据·数据库·分布式·mysql·oracle·金融·数据库架构
码士集团小青1 天前
Google 开源了啥,让 AI Agent 碰数据库不再是定时炸弹
数据库·oracle
Zenova EdgeOS1 天前
工业网关数据全链路加密实战:从传输、静态数据到密钥轮
数据库·oracle·边缘计算·工业网关
betazhou1 天前
Apache Seatunnel 抽取SQL server实时同步到Oracle(四)
数据库·oracle·apache·sql server·seatunnel
LMT流氓兔2 天前
第四单元——第17课:让回答边生成、边显示
服务器·数据库·人工智能·python·oracle·langchain
kyle~2 天前
DTO --- 数据封装
数据库·oracle·前后端
Lethehong3 天前
Oracle 加个字段,目标库就报错?KFS 用“先拆后组“打通异构 DDL
数据库·oracle
Web极客码3 天前
锁定真正的磁盘卡顿:我用 OpenCode 配合 eBPF 诊断 NVMe 队列深度延迟与 I/O 写放大
数据库·oracle
猫咪很可爱3 天前
Oracle RAC 启动失败排查:私网通信与内核参数优化实战
运维·数据库·oracle
张洛闻Eren3 天前
Ansible【第三课】:管理变量和事实
数据库·oracle