Sunday, 13 July 2008

schedules

BEGIN
DBMS_SCHEDULER.create_schedule ('S1',repeat_interval => 'FREQ=WEEKLY;BYHOUR=15;BYDAY=SUN',start_date => SYSTIMESTAMP);
DBMS_SCHEDULER.create_schedule ('S2',repeat_interval => 'FREQ=HOURLY;INTERVAL=2;BYDAY=MON,TUE,WED,THU,FRI,SAT;BYHOUR=8,9,10,11,12,13,14,15,16,17,18,19,20,21,22',start_date => SYSTIMESTAMP );
DBMS_SCHEDULER.create_schedule ('S3', repeat_interval =>'S1,S2',start_date => SYSTIMESTAMP);
END;
/


begin
dbms_scheduler.create_job
(job_name => 'TK',
job_type => 'PLSQL_BLOCK',
job_action=> 'begin select sysdate from dual; end;',
schedule_name=>'S3',
enabled=>true,
auto_drop=>false,
comments=>'Refresh the gift_advice table from ADVANCE.WORLD');
end;


BEGIN
dbms_scheduler.drop_schedule(
schedule_name => 'S1');
END;
/




CREATE OR REPLACE procedure SYS.print_schedule_dates
( schedule in varchar2,
start_date in timestamp with time zone default dbms_scheduler.stime(),
number_of_dates in pls_integer default 10 )
is date_after timestamp with time zone := start_date - interval '1' second;
next_date timestamp with time zone;
begin for i in 1 .. number_of_dates
loop
dbms_scheduler.evaluate_calendar_string
(schedule, start_date, date_after, next_date);
dbms_output.put_line(to_char(next_date,'DY DD-MON-YYYY (DDD-IW) HH24:MI:SS TZH:TZM TZR'));
date_after := next_date;
end loop;
end;
/


exec print_schedule_dates('S3');

No comments: