itpub 復活節最短sql(未完成程式碼)
CREATE OR REPLACE PACKAGE EASTER
IS
TYPE T IS TABLE OF VARCHAR2(9) INDEX BY BINARY_INTEGER;
S T;
D T;
E T;
N NUMBER;
A NUMBER;
B NUMBER;
Q NUMBER;
M NUMBER;
W NUMBER;
P NUMBER;
C NUMBER;
IS
TYPE T IS TABLE OF VARCHAR2(9) INDEX BY BINARY_INTEGER;
S T;
D T;
E T;
N NUMBER;
A NUMBER;
B NUMBER;
Q NUMBER;
M NUMBER;
W NUMBER;
P NUMBER;
C NUMBER;
PROCEDURE SHOWALLEASTERDAY;
PROCEDURE SHOWMAXOCCURENCEEASTERDAY;
PROCEDURE SHOWLEAPEASTERDAY;
PROCEDURE SHOWFOOLEASTERDAY;
PROCEDURE O(R T);
END;
/
CREATE OR REPLACE PACKAGE BODY EASTER
IS
PROCEDURE SHOWMAXOCCURENCEEASTERDAY;
PROCEDURE SHOWLEAPEASTERDAY;
PROCEDURE SHOWFOOLEASTERDAY;
PROCEDURE O(R T);
END;
/
CREATE OR REPLACE PACKAGE BODY EASTER
IS
PROCEDURE SHOWALLEASTERDAY
IS
IS
BEGIN
O(S);
END;
O(S);
END;
PROCEDURE SHOWMAXOCCURENCEEASTERDAY
IS
BEGIN
--SELECT COUNT(*) INTO C FROM TABLE(S);
--DBMS_OUTPUT.PUT_LINE(C);
NULL;
END;
IS
BEGIN
--SELECT COUNT(*) INTO C FROM TABLE(S);
--DBMS_OUTPUT.PUT_LINE(C);
NULL;
END;
PROCEDURE SHOWLEAPEASTERDAY
IS
BEGIN
IS
BEGIN
SELECT TO_CHAR(LEVEL+TO_DATE('0321','MMDD'),'MM-DD') BULK COLLECT INTO D
FROM DUAL
CONNECT BY LEVEL+TO_DATE('0321','MMDD')<=TO_DATE('0425','MMDD')
AND LEVEL+TO_DATE('0321','MMDD')>=TO_DATE('0322','MMDD');
FROM DUAL
CONNECT BY LEVEL+TO_DATE('0321','MMDD')<=TO_DATE('0425','MMDD')
AND LEVEL+TO_DATE('0321','MMDD')>=TO_DATE('0322','MMDD');
E:=D MULTISET EXCEPT S;
O(E);
END;
PROCEDURE SHOWFOOLEASTERDAY
IS
IS
J NUMBER;
BEGIN
BEGIN
FOR I IN 2011..2099 LOOP
IF S(I)='4-01' THEN
D(I):=S(I);
END IF;
END LOOP;
J:=D.FIRST;
FOR I IN 1..D.COUNT LOOP
D(J):=D.COUNT;
J:=D.NEXT(J);
END LOOP;
IF S(I)='4-01' THEN
D(I):=S(I);
END IF;
END LOOP;
J:=D.FIRST;
FOR I IN 1..D.COUNT LOOP
D(J):=D.COUNT;
J:=D.NEXT(J);
END LOOP;
O(D);
END;
END;
PROCEDURE O(R T)
IS
J NUMBER;
BEGIN
IS
J NUMBER;
BEGIN
J:=R.FIRST;
FOR I IN 1..R.COUNT LOOP
FOR I IN 1..R.COUNT LOOP
DBMS_OUTPUT.PUT(J||' ');
DBMS_OUTPUT.PUT_LINE(R(J));
J:=R.NEXT(J);
END LOOP;
END;
DBMS_OUTPUT.PUT_LINE(R(J));
J:=R.NEXT(J);
END LOOP;
END;
BEGIN
FOR I IN 2011..2099 LOOP
N:=I-1900;
A:=MOD(N,19);
B:=TRUNC((A*7+1)/19);
Q:=TRUNC(N/4);
M:=MOD(11*A+4-B,29);
W:=MOD(N+Q+31-M,7);
P:=25-M-W;
S(I):=CASE WHEN P>0 THEN '4-'||LPAD(P,2,0) WHEN P=0 THEN '3-31' ELSE '3-'||LPAD(-P,2,0) END;
END LOOP;
END;
FOR I IN 2011..2099 LOOP
N:=I-1900;
A:=MOD(N,19);
B:=TRUNC((A*7+1)/19);
Q:=TRUNC(N/4);
M:=MOD(11*A+4-B,29);
W:=MOD(N+Q+31-M,7);
P:=25-M-W;
S(I):=CASE WHEN P>0 THEN '4-'||LPAD(P,2,0) WHEN P=0 THEN '3-31' ELSE '3-'||LPAD(-P,2,0) END;
END LOOP;
END;
程式碼中問題:巢狀表型別,系統提供的有v KU$_VCNT := KU$_VCNT();(yang程式碼中)
2、巢狀表還有delete方法啊
3、日期函式,自己拼的有點繁瑣了
4、巢狀錶轉換成結果集查詢學習下。
5、自己程式碼中使用了索引表,往下做不動了哦
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25323853/viewspace-693674/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 復活節最短原始碼分析原始碼
- 復活節最短原始碼比賽原始碼
- XP風格復活節彩蛋的實現 (轉)
- 復活
- C++Builder和Delphi中的復活節彩蛋 (轉)C++UI
- ITPUB中秋節·斷帕山
- 復活賽
- 世界上最短的時鐘程式碼
- 微信活碼系統程式原始碼原始碼
- 恢復 SQL 被注入後的資料程式碼SQL
- 異常死亡程式的自動復活 (轉)
- ITPUB SQL大賽之BUG(八)SQL
- ITPUB SQL大賽之BUG(七)SQL
- ITPUB SQL大賽之BUG(六)SQL
- ITPUB SQL大賽之BUG(五)SQL
- ITPUB SQL大賽之BUG(四)SQL
- ITPUB SQL大賽之BUG(三)SQL
- ITPUB SQL大賽之BUG(二)SQL
- ITPUB SQL大賽之BUG(一)SQL
- httpclient編碼問題(未完成)HTTPclient
- 世界上最短的DVD解碼程式(附原始碼) (轉)原始碼
- DS圖—圖的最短路徑(不含程式碼框架)框架
- 迷宮問題——最短程式碼,不到70行
- 打贏復活賽,我活過來了
- 歷時 37 年,Windows 1.0 復活節彩蛋終於曝光:主角竟是“G 胖”!Windows
- 最短路徑——floyd演算法程式碼(c語言)演算法C語言
- ITPUB SQL大賽第三期SQL
- ITPUB SQL大賽第一期SQL
- ITPUB SQL大賽第二期SQL
- ITPUB SQL大賽第四期SQL
- 高二前復活感想
- SQL Server與最短路徑演算法SQLServer演算法
- 最短路徑——dijkstra演算法程式碼(c語言)演算法C語言
- curl 作者表示永遠不會在軟體中嵌入復活節彩蛋:boring is goodGo
- ITPUB SQL大賽第三期(二)SQL
- ITPUB SQL大賽第二期(二)SQL
- ITPUB SQL大賽第二期(一)SQL
- 自復制程式碼