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!
Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.
SQL> update tab_2 x set indi = NVL((SELECT 'MMM' FROM tab_1 WHERE id = x.id),'OOO'); 6 rows updated. SQL> commit; Commit complete. SQL> select * from tab_2; ID INDI ---------- ---------- A123 MMM A456 MMM A678 MMM A890 MMM B130 OOO C180 OOO 6 rows selected. SQL> select * from tab_1; ID ---------- A123 A456 A678 A890 SQL> select * from tab_2; ID INDI ---------- ---------- A123 MMM A456 MMM A678 MMM A890 MMM B130 OOO C180 OOO 6 rows selected. SQL>
SQL> select * from table1; ID ---------- A123 A456 A678 A890 SQL> select * from table2; ID INDI ---------- ----- A678 A456 A123 A666 A898 A890 6 rows selected SQL> SQL> update table2 t2 2 set INDI = ( 3 select decode((select 1 from table1 t1 where t1.id = t2.id),1,'MMM','OOO') from dual 4 ); 6 rows updated SQL> commit; Commit complete SQL> select * from table2; ID INDI ---------- ----- A678 MMM A456 MMM A123 MMM A666 OOO A898 OOO A890 MMM 6 rows selected
declare type t_type is table of rowid index by pls_integer; l_type t_type; cursor c1 is select rowid from table2; begin open c1; loop fetch c1 bulk collect into l_type limit 10000; exit when c1%notfound; forall i in l_type.FIRST .. l_type.LAST update table2 t2 set INDI = ( select decode((select 1 from table1 t1 where t1.id = t2.id),1,'MMM','OOO') from dual ) where t2.rowid = l_type(i); commit; end loop; close c1; end;
update TABLE2 a set INDI = case when exists(select 1 from TABLE1 b where b.ID = a.ID) then 'MMM' else 'OOO' end;