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.

相关推荐
奔跑吧树袋熊13 小时前
多租户隔离该做到哪一层:从连接池到 ORM 的取舍
开发语言·数据库·oracle·系统架构
YHHLAI14 小时前
从零理解 Agent Memory 管理:内存记忆、文件持久化与上下文截断
数据库·oracle
Aaron - Wistron15 小时前
Windows Server 配置
oracle
惜分飞16 小时前
记录一次0丢失的ORA-00354: 损坏重做日志块标头故障恢复---惜分飞
数据库·oracle
隔窗听雨眠16 小时前
Oracle TDE透明数据加密完全指南:从密钥库配置到生产运维的系统性实践
oracle·数据加密·tde
风哥2号1 天前
数据库教程FGMT13‑Oracle性能优化之数据仓库与分区表
数据库·oracle·性能优化
程序员清风1 天前
FastAPI 入门:用 Python 快速开发现代后端服务
python·oracle·fastapi
Zenova EdgeOS1 天前
工业网关数据持久化:从同步到 WAL 的工程实战
网络·数据库·oracle
oradh1 天前
Oracle UNDO 数据文件丢失处理(案例一)
数据库·oracle
El Shaddai.plus1 天前
达梦数据库的执行计划操作符介绍
数据库·oracle