游标问题,相当麻烦,各位帮忙看看
create or replace procedure SP_INT is
--记数器
rowlimit integer;
--定义类型
TYPE TYPE_ROW IS RECORD
(
aaaa VARCHAR2(30),
bbbb CHAR(1)
);
TYPE TYPE_TAB IS TABLE OF TYPE_ROW;
--定义v_tab为TYPE_TAB
v_tab TYPE_TAB;
--定义请求接口表游标
CURSOR CUR_INT is SELECT A.aaaa,C.bbbb FROM A
left join B on (A.id = c.id);
BEGIN
rowlimit:=1000;
OPEN CUR_INT;
LOOP
--定义1000条
FETCH CUR_INT BULK COLLECT INTO v_tab LIMIT rowlimit;
FOR i IN 1..v_tab.COUNT
SELECT aaaa into v_a from a;
LOOP
END LOOP;
--关闭游标
EXIT WHEN CUR_INT%notfound;
END LOOP;
END;
---这样的过程,老提示v_tab 类型错误。不是写法有问题,还是不能这样写。
各位帮忙看看。
------解决方案--------------------
SQL code
就这么几句语句,你竟然能搞出10个错误,这也是本事。 :)
修改后:
CREATE OR REPLACE PROCEDURE SP_INT IS
ROWLIMIT INTEGER;
TYPE TYPE_ROW IS RECORD(
AAAA VARCHAR2(30),
BBBB CHAR(1));
TYPE TYPE_TAB IS TABLE OF TYPE_ROW;
V_TAB TYPE_TAB;
CURSOR CUR_INT IS
SELECT A.AAAA, C.BBBB FROM A LEFT JOIN B ON (A.ID = C.ID);
BEGIN
ROWLIMIT := 1000;
OPEN CUR_INT;
LOOP
FETCH CUR_INT BULK COLLECT
INTO V_TAB LIMIT ROWLIMIT;
FOR I IN 1 .. V_TAB.COUNT LOOP
/* SELECT AAAA INTO V_A FROM A;
LOOP
END LOOP;*/
NULL;
END LOOP;
EXIT WHEN CUR_INT%NOTFOUND;
END LOOP;
CLOSE CUR_INT;
END;
/