Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to update the records using bulk collect

User_35O2QNov 6 2022 — edited Nov 6 2022

I tried to use the bulk collect in the large collecrtion of datas , i created the new table "jai" copying the entire set of records from employee table, But it is showing me an error, my procedure is a as follows
create or replace procedure dummy_sp
2 as
3 type name_rec as object (first_name varchar2(100),last_name varchar2(100),employee_id number);
4 type emp_typ is table of name_rec;
5 v_first_name varchar2(1000):='Allen';
6 v_data emp_typ;
7 cursor emp_c is select first_name,last_name,employee_id from jai;
8 begin
9 open emp_c;
10 fetch emp_c bulk collect into v_data;
11 close emp_c;
12 forall i in 1..v_data.last
13 update jai
14 set first_name=v_first_name
15 where employee_id=v_data(i).employee_id;
16 end;
17 /

It is showing me error like this
3/1 PLS-00540: object not supported in this context.
10/1 PL/SQL: SQL Statement ignored
10/31 PLS-00597: expression 'V_DATA' in the INTO list is of wrong type
13/1 PL/SQL: SQL Statement ignored
15/19 PL/SQL: ORA-22806: not an object or REF
15/19 PLS-00436: implementation restriction: cannot reference fields of
BULK In-BIND table of records

Kindly let me know the correct procedure to arrive at the answer or any alternative to arrive at the answeer...

Comments
Post Details
Added on Nov 6 2022
10 comments
4,914 views