|
原帖由 jboracle1981 于 2011-4-28 19:36 发表 ![]()
牛!
老大,干脆把这个
subtype w is varchar(999)
改成
subtype w is long算了吧,虽然意义不大。
土点就土点,应该不会出错吧
突破2000b
呵呵,要突破1200bytes,也不用这么变态且不能编译的方法。
将 substr(c(y),-2) = 1 这个条件改为 c(y) like '%01' 即可立减 4 bytes
最终为 1196 bytes
create or replace package easter is
procedure showAllEasterDay;
procedure showMaxOccurenceEasterDay;
procedure showLeapEasterDay;
procedure showFoolEasterDay;
end;
/
create or replace package body easter is
c dbms_sql.varchar2s;
subtype w is varchar(999);
s w;
x w;
v date := date '1-3-31';
procedure p(t w) is
begin
dbms_output.put_line(t);
for i in -30 .. 50 loop
c(i) := 0;
end loop;
for y in 2011 .. 2099 loop
s := y mod 19;
s := (11 * s + 4 - trunc((7 * s + 1) / 19)) mod 29;
x := 25 - s - (y - 2344 + trunc(y / 4) - s) mod 7;
c(y) := to_char(v + x, ' mm-dd');
c(x) := c(x) - 1;
s := sign(x - 1) + 40;
c(s) := least(+c(x), c(s));
end loop;
s := '';
end;
procedure showAllEasterDay is
begin
p('YEAR DAY');
for y in 2011 .. 2099 loop
p(y || c(y));
end loop;
end;
procedure z(w w, n w := 30, m w := -30) is
begin
for f in m .. n loop
if c(f) = w then
s := s || to_char(v + f, 'mm-dd/');
end if;
end loop;
s := rtrim(s, '/') || ' ' || -w || ' ';
end;
procedure showMaxOccurenceEasterDay is
begin
p('MAXOCC MO_CNT MAXOCC_3 MO3_CNT MAXOCC_4 MO4_CNT');
x := least(+c(40), c(41));
z(least(+x, c(39)));
z(c(39), 0);
z(x, 30, 1);
p(s);
end;
procedure showLeapEasterDay is
begin
p('ABSENT_START ABSENT_END');
for i in 22 - 31 .. 25 loop
x := to_char(v + i, 'mm-dd ');
if c(i) = 0 then
s := nvl(s, x);
end if;
if s = s and (i = 25 or c(i + 1) < 0) then
p(s || x);
end if;
end loop;
end;
procedure showFoolEasterDay is
begin
p('YEAR TOTAL');
for y in 2011 .. 2099 loop
if c(y) like '%01' then
p(y || ' ' || -c(40));
end if;
end loop;
end;
end;
/ |
|