Associate a scheduler job with a window

2k views Asked by At

Trying to associate a job with a window. Connection should work using the schedule_name but it does not seem to work.

Reproducible example

creating the window opens every other minute

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

OK, associating a job

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 for create_job clearly state

schedule_name - The name of the schedule, window, or window group associated with this job.

Whats the problem ???

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
1

There are 1 answers

3
Alen Oblak On

You are creating a WINDOW but associating the job with the SCHEDULE.

WINDOW != SCHEDULE

Create a SCHEDULE instead of WINDOW.

Update: actually, it is OK to associate a JOB with a WINDOW. But since the windows are in the SYS schema, you must supply the schema name in the parameter:

   schedule_name        => 'sys.traffic_window'