I would like to load data into a collection from various cursors. and below you can see a small example of the same. To simply put, I need to take columns from various tables and load it into a single table. Initially we were using a direct insert statement which was working fine, however it is causing issues recently. So we are trying to introduce a collection which would collect the data and from there we will load the data to the table.
declare
vin date;
cursor c1 is select emp_id.. from emp;
cursor c2 is select dept_id , ... from dept;
type t3 is table of t%rowtype;
t1 t3 := t3();
begin
for i in (select emp_id,dept_id,vin from dual)
loop
t1.extend;
t1(t1.count).load_date := i.vin;
t1(t1.count).emp_id := i.emp_id;
t1(t1.count).dept_no := i.dept_id;
end loop;
forall j in 1..t1.last
insert into t values (t1(j).emp_id,t1(j).dept_id,t1(j).load_date);
end;
When i tried to run this one, I'm getting an error stating PLS00308 :that constructor is not allowed as the origin of the assignment. Kindly help me on this.
Don't use PL/SQL, cursors or collection. Just use
INSERT INTO ... SELECT ...andJOINthe tables: