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.

相关推荐
执笔画情ora8 小时前
Postgresql数据库管理-pg_xact
数据库·postgresql·oracle
XDHCOM9 小时前
ORA-32152报错咋整啊,数据库操作遇到null number问题远程帮忙修复
服务器·数据库·oracle
jnrjian10 小时前
ORA-39012: Client detached EXPDP stop task DBMS_DATAPUMP
oracle
sbjdhjd12 小时前
RHCE | Web 服务器与 Nginx 全栈详解
linux·nginx·http·云原生·oracle·架构·web
阿坤带你走近大数据17 小时前
Oracle存储过程怎么写
数据库·oracle·存储过程
宇灬宇19 小时前
Oracle 到 PostgreSQL迁移(ora2pg)
数据库·postgresql·oracle
璞~21 小时前
DBeaver 连接达梦数据库(DM8)完整步骤
数据库·oracle
Gauss松鼠会21 小时前
openGauss数据库源码解析系列文章——存储引擎源码解析(一)
数据库·oracle·性能优化·database·opengauss
oradh1 天前
Oracle 11g tar包方式安装数据库软件
数据库·oracle
Leon-Ning Liu1 天前
Oracle 19C RAC升级到 26ai RAC
数据库·oracle