存储过程错误ERROR:procedure, function, package, or type is not allowed here

开源中国-总书记 发布于 2016/07/14 17:27
阅读 328
收藏 0
CREATE OR REPLACE PROCEDURE TEST_WEEK_QF IS
FIRSTDAYDATE  DATE;
LASTDAYDATE  DATE; 
MONDAY DATE; 
SUNDAY DATE; 
I INTEGER;
BEGIN
SELECT TO_DATE('20170101', 'yyyymmdd') INTO FIRSTDAYDATE FROM DUAL;
SELECT LAST_DAY(ADD_MONTHS(FIRSTDAYDATE,11)) INTO LASTDAYDATE FROM DUAL;
MONDAY:=FIRSTDAYDATE;
SELECT TRUNC(MONDAY,'iw') INTO SUNDAY FROM DUAL;
I:=1;
WHILE (SUNDAY <= LASTDAYDATE) LOOP
INSERT INTO test_week_qf(ID,WEEKXH,MONDAY,SUNDAY)VALUES (I,I,MONDAY,SUNDAY);
SELECT TRUNC(MONDAY,'iw')+7 INTO MONDAY FROM DUAL;
SELECT TRUNC(MONDAY,'iw')+6 INTO SUNDAY FROM DUAL;
I:=I+1;
END LOOP;
COMMIT;

END TEST_WEEK_QF;

编译错误 如下

加载中
0
开源中国-总书记
开源中国-总书记
CREATE OR REPLACE PROCEDURE TEST_WEEK_QF IS
FIRSTDAYDATE  DATE;
LASTDAYDATE  DATE; 
MONDAY DATE; 
SUNDAY DATE; 
I INTEGER;
BEGIN
SELECT TO_DATE('20170101', 'yyyymmdd') INTO FIRSTDAYDATE FROM DUAL;
SELECT LAST_DAY(ADD_MONTHS(FIRSTDAYDATE,11)) INTO LASTDAYDATE FROM DUAL;
MONDAY:=FIRSTDAYDATE;
SELECT TRUNC(MONDAY,'iw') INTO SUNDAY FROM DUAL;
I:=1;
WHILE (SUNDAY <= LASTDAYDATE) LOOP
INSERT INTO test_week_qf(ID,WEEKXH,MONDAY,SUNDAY)VALUES (I,I,MONDAY,SUNDAY); 
SELECT TRUNC(MONDAY,'iw')+7 INTO MONDAY FROM DUAL;
SELECT TRUNC(MONDAY,'iw')+6 INTO SUNDAY FROM DUAL;
I:=I+1;
END LOOP;
COMMIT;
END TEST_WEEK_QF;



返回顶部
顶部