Oracle ORA-00904:使用forall时标识符无效
当我运行以下程序块时,我得到错误:Oracle ORA-00904:使用forall时标识符无效,oracle,plsql,sql-insert,ora-00904,Oracle,Plsql,Sql Insert,Ora 00904,当我运行以下程序块时,我得到错误: 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
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;
/
values子句中PL/SQL表引用周围缺少括号。更改此行:
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
哦,上帝,你是对的。我错过了。现在工作。谢谢!
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