repeat_interval & Easter

Hello

How do an additive in the annex to the public_holidays, that is to say including the Easter. It's... dates that are not specific date and the same each year, but according to other stuff?

I know that I can make one for 2011, 2012 etc. But I wish I had a repeat_interval giving Easter.

Is this possible without having to generate a new every year?

Concerning
Mette

You asked for it :)

SQL > Rem a function to print the dates
SQL > cal_string Rem: a timing chain (AS FREQ = DAILY..);
SQL > Rem start_date: report dates starting on or after this date
SQL > nr_dates Rem: number of return dates;
SQL >
SQL > create or replace procedure print_dates
() 2
3 cal_string in varchar2,
start_date timestamp with time zone 4,.
5 nr_of_dates in pls_integer
8 g
7 is
8 date_after timestamp with time zone: = start_date - interval of second '1';
9 next_execution_date timestamp with time zone;
10 starts
11 dbms_output.put_line ('-->');
12 because me in 1... nr_of_dates
loop 13
14 dbms_scheduler.evaluate_calendar_string
15 (cal_string, start_date, date_after, next_execution_date);
16
17 dbms_output.put_line (to_char (next_execution_date,
18 ' DY DD-MON-YYYY (DDD - IW) HH24:MI:SS TZDS TZH TZR '));
19
20 date_after: = next_execution_date;
21 end of loop;
22 end;
23.

Created procedure.

SQL >
SQL > Rem create us a calendar to be used as a user-defined schedule.
SQL > Rem this calendar consists of all of the dates of Easter using the clause bydate
SQL > Rem you could hard-code the list of dates, but rather to generate the list of Easter
SQL > dates Rem with a helper function butcher_easter_ymd that implements
SQL > Rem an algorithm to determine Easter
SQL > dates of Rem.
SQL >
SQL > create or replace procedure butcher_easter_ymd
() 2
3 years in pls_integer,
4 months on pls_integer,
day 5 pls_integer
8 g
7 is
8 a number: = MOD(year,19);
9 number of b: = TRUNC(year/100);
number 10 c: = MOD(year,100);
Number 11 d: = TRUNC(b/4);
12 number e: = MOD (b, 4);
13 number of f: = TRUNC ((b+8)/25);
Number 14 g: = TRUNC ((b-f+1)/3);
Number 15 h: = MOD(19*a+b-d-g+15,30);
16 I have COMP: = TRUNC(c/4);
17 k number: = MOD (c, 4);
Number 18 l: = MOD(32+2*e+2*i-h-k,7);
number 19 m: = TRUNC ((a+11*h+22*l)/451);
20 number of Easter_Month: = TRUNC ((h+l-7*m+114)/31);
number 21 p: = MOD(h+l-7*m+114,31);
22 Easter_Date number: = p + 1;
23
Start 24
25 months: = Easter_Month;
day 26: = Easter_Date;
27 end;
28.

Created procedure.

SQL > show errors
No errors.
SQL >
SQL > function of A Rem to generate the freq = daily; bydate = {list of dates of Easter}
SQL >
SQL > create or replace procedure generate_easter_schedule
() 2
3 y_start in pls_integer,
4 y_end in pls_integer
5)
6 is
easter_schedule 7 varchar2 (2000);
8 easter_d pls_integer;
easter_m 9 pls_integer;
10 sep varchar2 (1);
11 start
12 easter_schedule: = ' FREQ = DAILY; BYDATE =';
13 Sep: = ";
14 because I in y_start... y_end loop
15 butcher_easter_ymd (i, easter_m, easter_d);
16 easter_schedule: = easter_schedule | Ms
17           || to_char(i*10000+easter_m*100+easter_d);
Sep 18: = ', ';
19 end of loop;
start at 20
21 dbms_scheduler.drop_schedule('easter');
22 exception when other then null;
23 end;
24 dbms_scheduler.create_schedule ("Easter", repeat_interval-online easter_schedule,
start_date 25 =>
26 to_timestamp_tz (January 1, 2008 09:00 "," DD-MON-YYYY HH24:MI:SS'));)
27
28 end;
29.

Created procedure.

SQL >
SQL > show errors
No errors.
SQL >
SQL >
SQL > Rem run the generator of the GET, the timing of Easter
SQL > set serveroutput on
SQL >
SQL >
SQL > exec generate_easter_schedule (2009,2070);

PL/SQL procedure successfully completed.

SQL >
SQL > select repeat_interval from the user_scheduler_schedules where schedule_name = 'EASTER ';

REPEAT_INTERVAL
--------------------------------------------------------------------------------
FREQ = ALL DAYS; BYDATE = 20090412, 20100404, 20110424, 20120408, 20130331, 20140420, 20150405
20160327,20170416,20180401,20190421,20200412,20210404,20220417,20230409,2024033
1,20250420,20260405,20270328,20280416,20290401,20300421,20310413,20320328,203304
17,20340409,20350325,20360413,20370405,20380425,20390410,20400401,20410421,20420
406,20430329,20440417,20450409,20460325,20470414,20480405,20490418,20500410,2051
0402,20520421,20530406,20540329,20550418,20560402,20570422,20580414,20590330,206
00418,20610410,20620326,20630415,20640406,20650329,20660411,20670403,20680422,20
690414,20700330

SQL >
SQL > / *.
SQL > use planning of Easter as a frequency set by the user to find out all the
SQL > holidays Easter-related
SQL >-47 - Carnival, Shrove Tuesday, Fat Tuesday, Shrove Tuesday, etc.
SQL > - 46 - Ash Wednesday (-40 Sunday if not counted)
SQL > - 7 - Palm Sunday
SQL > - 3 - Thursday Holy, Holy Thursday
SQL > - 2 - Friday St
SQL > - 1 - Saturday Saint
SQL > 1 - Easter Sunday
SQL > 2 - Easter Monday
SQL > 40 - ascension day (Thursday)
SQL > 50 - Pentecost
SQL > 51 - Whit Monday
SQL > 60 - corpus christy
SQL > * /.
SQL >
SQL > /.

REPEAT_INTERVAL
--------------------------------------------------------------------------------
FREQ = ALL DAYS; BYDATE = 20090412, 20100404, 20110424, 20120408, 20130331, 20140420, 20150405
20160327,20170416,20180401,20190421,20200412,20210404,20220417,20230409,2024033
1,20250420,20260405,20270328,20280416,20290401,20300421,20310413,20320328,203304
17,20340409,20350325,20360413,20370405,20380425,20390410,20400401,20410421,20420
406,20430329,20440417,20450409,20460325,20470414,20480405,20490418,20500410,2051
0402,20520421,20530406,20540329,20550418,20560402,20570422,20580414,20590330,206
00418,20610410,20620326,20630415,20640406,20650329,20660411,20670403,20680422,20
690414,20700330

SQL > Rem the calendar below expression generates all associates of Easter holiday.
SQL > Rem remove all or part of the BYSETPOS posts to remove the holidays from the list
SQL > Rem, e.g. FREQ = reports alone EASTER Easter Day
SQL > start
2 print_dates ("FREQ = EASTER; BYDAY = SUN, MON, MAR, SEA, GAME, SAT, SAM;' |
3 'BYSETPOS =-47-46 - 7, -3, -2, -1, 1, 2, 40, 50, 51, 60',
to_timestamp_tz 4 (January 1, 2010 09:00 "," DD-MON-YYYY HH24:MI:SS'), 25);
5 end;
4 m
-->
TUESDAY, 16 FEBRUARY 2010 (07-047) 09:00 - 07 - 07:00
WEDNESDAY, 17 FEBRUARY 2010 (07-048) 09:00 - 07 - 07:00
SUNDAY, MARCH 28, 2010 (087-12) 09:00 - 07 - 07:00
THURSDAY, APRIL 1, 2010 (091-13) 09:00 - 07 - 07:00
FRIDAY, APRIL 2, 2010 (13 092) 09:00 - 07 - 07:00
SATURDAY, 3 APRIL 2010 (093-13) 09:00 - 07 - 07:00
SUNDAY, 4 APRIL 2010 (094-13) 09:00 - 07 - 07:00
MONDAY, APRIL 5, 2010 (14 095) 09:00 - 07 - 07:00
THURSDAY, 13 MAY 2010 (133-19) 09:00 - 07 - 07:00
SUNDAY, MAY 23, 2010 (143-20) 09:00 - 07 - 07:00
MONDAY, MAY 24, 2010 (144-21) 09:00 - 07 - 07:00
WEDNESDAY, JUNE 2, 2010 (153-22) 09:00 - 07 - 07:00
TUESDAY, MARCH 8, 2011 (067-10) 09:00 - 07 - 07:00
WEDNESDAY, MARCH 9, 2011 (068-10) 09:00 - 07 - 07:00
SUNDAY, APRIL 17, 2011 (107-15) 09:00 - 07 - 07:00
THURSDAY, APRIL 21, 2011 (111-16) 09:00 - 07 - 07:00
FRIDAY, APRIL 22, 2011 (112-16) 09:00 - 07 - 07:00
SATURDAY, APRIL 23, 2011 (113-16) 09:00 - 07 - 07:00
SUNDAY, APRIL 24, 2011 (114-16) 09:00 - 07 - 07:00
MONDAY, APRIL 25, 2011 (115-17) 09:00 - 07 - 07:00
THURSDAY JUNE 2, 2011 (153-22) 09:00 - 07 - 07:00
SUNDAY, JUNE 12, 2011 (163-23) 09:00 - 07 - 07:00
MONDAY, JUNE 13, 2011 (164-24) 09:00 - 07 - 07:00
WEDNESDAY, JUNE 22, 2011 (173-25) 09:00 - 07 - 07:00
TUESDAY, FEBRUARY 21, 2012 (08-052) 09:00 - 07 - 07:00

PL/SQL procedure successfully completed.

SQL >
SQL > start
2 print_dates ("FREQ = EASTER;',")
to_timestamp_tz 3 (January 1, 2010 09:00 "," DD-MON-YYYY HH24:MI:SS'), 10);
4 end;
7 m
-->
SUNDAY, 4 APRIL 2010 (094-13) 09:00 - 07 - 07:00
SUNDAY, APRIL 24, 2011 (114-16) 09:00 - 07 - 07:00
SUNDAY, APRIL 8, 2012 (099-14) 09:00 - 07 - 07:00
SUNDAY, MARCH 31, 2013 (090-13) 09:00 - 07 - 07:00
SUNDAY, APRIL 20, 2014 (110-16) 09:00 - 07 - 07:00
SUNDAY, APRIL 5, 2015 (095-14) 09:00 - 07 - 07:00
SUNDAY, MARCH 27, 2016 (087-12) 09:00 - 07 - 07:00
SUNDAY, APRIL 16, 2017 (106-15) 09:00 - 07 - 07:00
SUNDAY, APRIL 1, 2018 (091-13) 09:00 - 07 - 07:00
SUNDAY, APRIL 21, 2019 (111-16) 09:00 - 07 - 07:00

PL/SQL procedure successfully completed.

SQL > Rem report Carnival
SQL > start
2 print_dates ("FREQ = EASTER; BYSETPOS =-47; BYDAY = SUN, MON, MAR, SEA, GAME, SAT, SAM '.
to_timestamp_tz 3 (January 1, 2010 09:00 "," DD-MON-YYYY HH24:MI:SS'), 10);
4 end;
7 m
-->
TUESDAY, 16 FEBRUARY 2010 (07-047) 09:00 - 07 - 07:00
TUESDAY, MARCH 8, 2011 (067-10) 09:00 - 07 - 07:00
TUESDAY, FEBRUARY 21, 2012 (08-052) 09:00 - 07 - 07:00
TUESDAY, FEBRUARY 12, 2013 (07-043) 09:00 - 07 - 07:00
TUESDAY, MARCH 4, 2014 (063-10) 09:00 - 07 - 07:00
TUESDAY, FEBRUARY 17, 2015 (08-048) 09:00 - 07 - 07:00
TUESDAY, FEBRUARY 9, 2016 (040-06) 09:00 - 07 - 07:00
TUESDAY, FEBRUARY 28, 2017 (059-09) 09:00 - 07 - 07:00
TUESDAY, FEBRUARY 13, 2018 (07-044) 09:00 - 07 - 07:00
TUESDAY, MARCH 5, 2019 (064-10) 09:00 - 07 - 07:00

PL/SQL procedure successfully completed.

SQL > exit

Tags: Database

Similar Questions

Maybe you are looking for