I can define a one-column table and bulk collect into it. i.e:
create type table_of_strings as table of varchar2(200);
DECLARE
l_tab table_of_strings;
BEGIN
select emp_name bulk collect into l_tab from emp;
END;
But how do I collect into multi-column tables? Say:
create type emp_row as object (emp_name varchar2(200), emp_salary Number);
create type emp_table as table of emp_row ;
DECLARE
l_tab emp_table ;
BEGIN
-- I have tried things like this but would fail:
select (emp_name, emp_salary) bulk collect into l_tab from emp;
select emp_name, emp_salary bulk collect into l_tab from emp;
select * bulk collect into l_tab from (
select emp_name, emp_salary from emp);
END;
Thank you in advance! Peter
Like this:
Here's a slightly modified example based on Scott's schema.
PL/SQL code: