Tuesday, August 20, 2024

bulk collect with dbms

 declare

v_first_name varchar2(1000):='Sunny';

t_no     sys.odcinumberlist;

t_fname  sys.odcivarchar2list;

t_lname  sys.odcivarchar2list;

t_rfname sys.odcivarchar2list;

        cursor emp_c

          is

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

                    first_name,

                    last_name,

                    employee_id

              from  jai;

         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';

     open emp_c;

     fetch emp_c bulk collect into t_rfname,t_fname, t_lname,t_no;

     close emp_c;

  --

       for x in t_no.first .. t_no.last loop

       dbms_output.put_line('Number = '||t_no(x) ||' The First Name = '|| t_fname(x));

     end loop; 

commit;

end;

/

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;

Tuesday, August 29, 2023

Sunday, May 30, 2021

Learn Oracle for free

 https://m.youtube.com/watch?v=Q5JM8nWWfnI&list=PLc9GCtRxQqZgvbfREKjy1Vi9X7Rle0Nhs&index=1&t=9s

Monday, September 21, 2020

Thursday, September 17, 2020

Oracle Select all column and one in the begining

Oracle Select all column and one in the begining

example

 select i.BONUS_ITEM_FLAG,i.* 

from SAL_INVOICES_ITEMS i ;