declare cursor order_cursor
is (select sheetnumber from scott.t where ID='111');--查询需要修改的sheetNUMBER
TYPE tp_table_stock AS TABLE OF NUMBER;
v_sheet_num tp_table_stock;
begin
--打开游标--
open order_cursor;
--开始循环游标变量--
fetch order_cursor bulk collect into V_sheet_num limit 20000;
for i in 1..v_sheet_num.count loop --返回被 FETCH语句执行的最后游标的状态--
begin
dbms_output.put_line(1111)
end;
end;
PLS-00642: local collection types not allowed in SQL statements (SQL语句中不允许使用本地集合类型)存储过程中报此错误。
解决方案:
不允许使用局部集合类型。
先在数据库中创建一个类型
CREATE OR REPLACE TYPE tp_table_stock AS TABLE OF NUMBER;
然后再使用该类型。
SQL> CREATE OR REPLACE TYPE id AS TABLE OF NUMBER;
2 /
Type created.
declare
v_sheet_num scott.accnt_number_type;
cursor order_cursor
is (select NAME from scott.t where ID='111');--查询需要修改的sheetNUMBER
begin
--打开游标--
open order_cursor;
--开始循环游标变量--
fetch order_cursor bulk collect into V_sheet_num limit 10;
for i in 1..v_sheet_num.count loop --返回被 FETCH语句执行的最后游标的状态--
dbms_output.put_line('1111');
end loop;
close order_cursor;
end;