drop table tbl_yyy
ORA-00942: table or view does not existMore Details: https://docs.oracle.com/error-help/db/ora-00942
drop table tbl_xxx
ORA-00942: table or view does not existMore Details: https://docs.oracle.com/error-help/db/ora-00942
create table tbl_yyy (cola number, colb number, colc number)
Table created.
insert into tbl_yyy
select level, level*10, level+1 from dual connect by level <= 5
5 row(s) inserted.
create table tbl_xxx
as select * from tbl_yyy where 1=2
Table created.
declare
/* NB: define this collection using the appropriate name */
type new_keys is table of table_xxx.cola%type;
col_res new_keys;
begin
INSERT INTO TBL_XXX
SELECT COLA * 10, COLB, COLC
FROM TBL_YYY
RETURNING tbl_xxx.COLA bulk collect INTO COL_RES;
for idx in 1 .. col_res.count() loop
dbms_output.put_line('tbl_yyy.cola = ' || col_res(idx));
end loop;
end;
ORA-06550: line 9, column 15: PL/SQL: ORA-00933: SQL command not properly endedMore Details: https://docs.oracle.com/error-help/db/ora-06550
declare
/* NB: define this collection using the appropriate name */
type new_rows is table of tbl_xxx%rowtype;
rec_xxx new_rows;
type new_keys is table of tbl_xxx.cola%type;
col_xxx new_keys;
begin
SELECT COLA * 10, COLB, COLC
bulk collect into rec_xxx
FROM TBL_YYY;
forall idx in 1 .. rec_xxx.count()
INSERT INTO TBL_XXX
values rec_xxx(idx)
RETURNING tbl_xxx.COLA bulk collect INTO col_xxx
;
for idx in 1 .. rec_xxx.count() loop
dbms_output.put_line('tbl_xxx.cola = ' || col_xxx(idx));
end loop;
end;
tbl_xxx.cola = 10
tbl_xxx.cola = 20
tbl_xxx.cola = 30
tbl_xxx.cola = 40
tbl_xxx.cola = 50