Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,31 @@ a|`FREQ=DAILY;` +

== 使用示例

=== 计算日历表达式的下一次匹配时间

使用 `EVALUATE_CALENDAR_STRING` 可以在不创建或启用作业的情况下检查重复表达式。该过程通过第四个参数返回下一次匹配的时间。下面的示例使用 UTC,从 7 月 1 日中午之后查找,每天 09:30 的下一次匹配为 7 月 2 日。

[source,sql]
----
SET TIME ZONE 'UTC';

DECLARE
next_run TIMESTAMP WITH TIME ZONE;
BEGIN
DBMS_SCHEDULER.EVALUATE_CALENDAR_STRING(
'FREQ=DAILY;BYHOUR=9;BYMINUTE=30;BYSECOND=0',
CAST('2026-01-01 00:00:00 +00:00' AS TIMESTAMP WITH TIME ZONE),
CAST('2026-07-01 12:00:00 +00:00' AS TIMESTAMP WITH TIME ZONE),
next_run);
RAISE NOTICE '%', next_run AT TIME ZONE 'UTC';
END;
/

RESET TIME ZONE;
----

NOTICE 输出 `2026-07-02 09:30:00`。示例结束后恢复会话时区。

=== 在当前会话运行作业

即使后台调度关闭,也可以用 `RUN_JOB` 立即执行。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,31 @@ a|`FREQ=DAILY;` +

== Examples

=== Evaluate a Calendar Expression

Use `EVALUATE_CALENDAR_STRING` to check a repeat expression without creating or enabling a job. It returns the next matching timestamp through its fourth argument. This example uses UTC and searches after noon on July 1; the next daily 09:30 occurrence is July 2.

[source,sql]
----
SET TIME ZONE 'UTC';

DECLARE
next_run TIMESTAMP WITH TIME ZONE;
BEGIN
DBMS_SCHEDULER.EVALUATE_CALENDAR_STRING(
'FREQ=DAILY;BYHOUR=9;BYMINUTE=30;BYSECOND=0',
CAST('2026-01-01 00:00:00 +00:00' AS TIMESTAMP WITH TIME ZONE),
CAST('2026-07-01 12:00:00 +00:00' AS TIMESTAMP WITH TIME ZONE),
next_run);
RAISE NOTICE '%', next_run AT TIME ZONE 'UTC';
END;
/

RESET TIME ZONE;
----

The notice reports `2026-07-02 09:30:00`. The example restores the session time zone afterward.

=== Run a Job in the Current Session

`RUN_JOB` executes immediately even when background scheduling is off.
Expand Down