0

While using the bulk collect,I am geeting following errors. "PLS-00597: expression 'EMP_REC' in the INTO list is of wrong type"

Can help me how to resolve it.

create table emp_det 
( 
emp_id number, 
ename varchar2(3), 
salary number, 
dept_id number 
);
 type type_emp_rec is record 
 ( 
    v_emp_rec emp_det%rowtype 
 ); 
   type cl_emp_rec is table of type_emp_rec; 
    emp_rec cl_emp_rec; 
 
begin 
 
    select *  bulk collect into emp_rec  from emp_det; 
      
end;
Alex Poole
  • 183,384
  • 11
  • 179
  • 318
Sunny
  • 11
  • 3

1 Answers1

1

You are using the table row definition as a pseudo record type, so you don't need to declare your own; and certainly not with that row type as a field within your own record.

You can just make your collection type refer to the row type directly:

declare
    type cl_emp_rec is table of emp_det%rowtype;
    emp_rec cl_emp_rec;
begin
    select *
    bulk collect into emp_rec
    from emp_det;
end;
/

db<>fiddle

Alex Poole
  • 183,384
  • 11
  • 179
  • 318