【问题标题】:How to schedule a job in SQL Developer如何在 SQL Developer 中安排作业
【发布时间】:2014-04-08 08:31:47
【问题描述】:

我想安排一个程序在特定时间运行,每天 3 次:12:00、16:00 和 18:30。 有没有办法创建这样的作业(使用标准 SQL Developer 作业向导)?

我通过设置 BYHOUR = 12,16,18 和 BYMINUTE = 0,30 安排了一个作业,但是它每天开始六次,这不是我想要的。

提前感谢您的提示!

【问题讨论】:

    标签: oracle-sqldeveloper jobs schedule


    【解决方案1】:

    如果您不想创建两个作业,最简单的方法是创建两个计划。您可以通过 Schedules->New Schedule 上下文菜单项或从工作表执行此操作:

    begin
      dbms_scheduler.create_schedule(schedule_name => 'sched_1',
        repeat_interval => 'FREQ=MINUTELY;BYHOUR=12,16;BYMINUTE=0');
      dbms_scheduler.create_schedule('sched_2',
        repeat_interval => 'FREQ=MINUTELY;BYHOUR=18;BYMINUTE=30');
    end;
    /
    

    然后在作业向导中,将“重复间隔”设置为 SCHED_1,SCHED_2。当然,您可能希望使用更有意义的名称...

    您可以通过以下方式检查组合计划何时运行 - 在当前时间之后 -

    set serveroutput on;
    declare
      start_date timestamp with time zone;
      return_date_after timestamp with time zone;
      next_run_date timestamp with time zone;
    begin
      start_date := cast(sysdate as timestamp with time zone);
    
      for i in 1 .. 8 loop
        return_date_after := nvl(next_run_date, start_date);
    
        dbms_scheduler.evaluate_calendar_string(
          calendar_string => 'sched_1,sched_2',
          start_date => start_date,
          return_date_after => return_date_after,
          next_run_date => next_run_date);
    
        dbms_output.put_line('Will run at: '
          || to_char(next_run_date, 'YYYY-MM-DD HH24:MI:SS'));
      end loop;
    end;
    /
    
    Will run at: 2014-04-08 16:00:18
    Will run at: 2014-04-08 18:30:18
    Will run at: 2014-04-09 12:00:18
    Will run at: 2014-04-09 16:00:18
    Will run at: 2014-04-09 18:30:18
    Will run at: 2014-04-10 12:00:18
    Will run at: 2014-04-10 16:00:18
    Will run at: 2014-04-10 18:30:18
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-01-05
      • 1970-01-01
      • 1970-01-01
      • 2010-09-12
      • 1970-01-01
      • 2014-04-02
      • 2019-01-03
      相关资源
      最近更新 更多