当我运行以下块时,我收到错误:
ORA-00904: Invalid identifier in "forall".
有人可以帮我解决一下吗?
列“ID”是12c标识列,因此编号。
drop table t1 cascade constraints purge;
create table t1 (
c1 number
);
set serveroutput on;
declare
type l_t2 is table of number;
l_c1 l_t2;
begin
select ID
bulk collect into l_c1
from IDTABLE;
dbms_output.put_line('Number of records: ' || sql%rowcount);
forall i in l_c1.first..l_c1.last
insert into t1 values l_c1(i);
end;
/
答案 0 :(得分:2)
您在values子句中的PL / SQL表引用周围缺少括号。改变这一行:
insert into t1 values l_c1(i);
到
insert into t1 values (l_c1(i));
没有它们,它认为l_cl
是某种类型的模式级对象,它不存在;因此你看到的错误。它们有效:
set serveroutput on;
declare
type l_t2 is table of number;
l_c1 l_t2;
begin
select ID bulk collect into l_c1 from IDTABLE;
dbms_output.put_line('Number of records: ' || sql%rowcount);
forall i in l_c1.first..l_c1.last
insert into t1 values (l_c1(i));
end;
/
PL/SQL procedure successfully completed.
Number of records: 2