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.

相关推荐
wytraining20 分钟前
快速入门 FastAPI 项目
jvm·oracle·fastapi
安当加密4 小时前
SQL Server 数据库安全新范式:TDE 透明加密+ DBG数据库安全网关 双重装甲
数据库·oracle
Irene19914 小时前
Oracle 21c XE 安装后默认不包含HR等示例表,CO 模式、SCOTT 模式安装过程记录
数据库·oracle
oradh5 小时前
Oracle数据库序列和同义词概述
数据库·oracle·数据库基础·数据库入门·oracle序列·oracle同义词
你觉得脆皮鸡好吃吗5 小时前
SQL注入 高权限注入(引入概念)
网络·数据库·sql·oracle·网络安全学习
m0_737539376 小时前
数据库主从复制和读写分离
数据库·oracle
Irene19918 小时前
(AI总结版)完整操作流程:从零配置 Oracle 21c XE 开发环境(安装 CO 示例、安装 SCOTT 教学示例)
数据库·oracle
唐骁虎8 小时前
使用SQLAlchemy查询Pandas DataFrame
数据库·oracle·pandas
杨云龙UP8 小时前
Oracle / ODA环境TRACE、alert日志定位与ADRCI清理 SOP_20260423
linux·运维·服务器·数据库·oracle
colofullove9 小时前
推导中异常处理
数据库·oracle