Q:

ORA-00904: Invalid identifier when using forall

When i run the following block, I get the error: 
ORA-00904: Invalid identifier in "forall". 

Can somebody please help me fix it? 
The column "ID" is an 12c identity column, so number. 
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;
/

A:

You're missing parentheses around the PL/SQL table reference in the values clause.  Change this line:
    insert into t1 values l_c1(i);

to
    insert into t1 values (l_c1(i));

Without them it thinks l_cl is a schema-level object of some kind, which doesn't exist; hence the error you see.  With them it works:
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

