尝试将作业与窗口关联。连接应该使用schedule_name工作,但它似乎不起作用。
可重复的例子
创建窗口每隔一分钟打开
SQL> begin
2 DBMS_SCHEDULER.CREATE_WINDOW (
3 window_name => 'traffic_window',
4 resource_plan => null,
5 repeat_interval => 'FREQ=minutely;interval=2',
6 duration => interval '1' minute
7 );
8 END;
9 /
PL/SQL procedure successfully completed.
SQL> select WINDOW_NAME,SCHEDULE_NAME,SCHEDULE_TYPE,ENABLED,ACTIVE from all_scheduler_windows;
WINDOW_NAME SCHEDULE_NAME SCHEDULE ENABL ACTIV
------------------------------ ----------------------------------- -------- ----- -----
TRAFFIC_WINDOW CALENDAR TRUE TRUE
确定,关联作业
SQL> exec dbms_scheduler.drop_job('test_window_job',true);
PL/SQL procedure successfully completed.
SQL> begin
2 dbms_scheduler.create_job (
3 job_name => 'test_window_job',
4 job_type => 'PLSQL_BLOCK',
5 job_action => 'begin test_func(70,''start'',0,null); end;',
6 schedule_name => 'traffic_window',
7 enabled => false,
8 auto_drop => true
9 );
10
11 dbms_scheduler.set_attribute ('test_window_job','max_runs',1);
12 dbms_scheduler.set_attribute ('test_window_job','stop_on_window_close',true);
13 end;
14 /
PL/SQL procedure successfully completed.
SQL> exec dbms_scheduler.enable('test_window_job');
BEGIN dbms_scheduler.enable('test_window_job'); END;
*
ERROR at line 1:
ORA-27481: "HAKI.TEST_WINDOW_JOB" has an invalid schedule
ORA-27476: "HAKI.TRAFFIC_WINDOW" does not exist
ORA-06512: at "SYS.DBMS_ISCHED", line 2751
ORA-06512: at "SYS.DBMS_SCHEDULER", line 1794
ORA-06512: at line 1
Docs create_job
明确说明
schedule_name - 计划,窗口或窗口组的名称 与这份工作有关。
问题是什么?
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
答案 0 :(得分:0)
您正在创建WINDOW
,但将作业与SCHEDULE
相关联。
WINDOW
!= SCHEDULE
创建SCHEDULE
而不是WINDOW
。
更新:实际上,可以将JOB
与WINDOW
相关联。但由于窗口在SYS模式中,因此必须在参数中提供模式名称:
schedule_name => 'sys.traffic_window'