我试图使用带有光标的前导功能来显示雇用日期,但是我收到此错误消息-PLS-00435:不能在FORALL内部使用没有BULK In-BIND的DML语句。请指导我。
SET SERVEROUTPUT ON
DECLARE
CURSOR C_11 IS SELECT * FROM EMP;
TYPE DD IS TABLE OF EMP%ROWTYPE;
CC DD;
VV EMP.HIREDATE%TYPE;
GG EMP.HIREDATE%TYPE;
BEGIN
OPEN C_11;
LOOP
FETCH C_11 BULK COLLECT INTO CC LIMIT 1000;
FORALL I IN CC.FIRST..CC.LAST
SELECT HIREDATE,LEAD(HIREDATE) OVER(ORDER BY HIREDATE) INTO VV,GG FROM EMP;
DBMS_OUTPUT.PUT_LINE (VV ||' '||GG);
EXIT WHEN C_11%NOTFOUND;
END LOOP;
CLOSE C_11;
END;
答案 0 :(得分:2)
PLS-00435:不能在内部使用没有BULK In-BIND的DML语句 永远。
FORALL
语句仅用于INSERT
/ UPDATE
或DELETE
。它不支持SELECT
。
阅读FORALL
限制:
https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/forall_statement.htm
或者,您也可以如下所示:
DECLARE
CURSOR c_11 IS
SELECT hiredate,
LEAD(hiredate) OVER( ORDER BY hiredate ) DT
FROM emp;
TYPE dd IS TABLE OF c_11%rowtype;
cc dd;
BEGIN
OPEN c_11;
LOOP
FETCH c_11 BULK COLLECT INTO cc LIMIT 100;
FOR i IN 1..cc.count
LOOP
dbms_output.put_line(cc(i).hiredate || ' -- ' || cc(i).dt);
END LOOP;
EXIT WHEN c_11%notfound;
END LOOP;
CLOSE c_11;
END;