Pages

Tuesday, August 20, 2024

How to update the records using bulk collect

 declare

v_first_name varchar2(1000):='Sunny';

        cursor emp_c

          is

            select  replace(first_name,'Sundar','Sunny') rfirst_name,

                    first_name,

                    last_name,

                    employee_id

              from  emp_test

where first_name ='Sundar';

         type emp_typ

           is table of emp_c%rowtype;

         v_data emp_typ;

    begin

        open emp_c;

        fetch emp_c

           bulk collect

           into v_data;

        close emp_c;

        forall i in 1..v_data.last

          update jai

             set first_name=v_data(i).rfirst_name

           where first_name ='Sundar';

commit;

end;

No comments:

Post a Comment