user3380298 user3380298 - 2 months ago 22
SQL Question

ORACLE SQL/PLSQL TO replace value wherever possible from a different table

Can any one help with SQL/PLSQL for the below scenario.
enter image description here

The result should change the value of TABLE 1 to the following (It should replace previous value with new value where ever possible)
enter image description here


You could write a stored function that does that:

function replaceTable2(s varchar2) returns varchar2 is
  r varchar2(32000);
  r := s;
  for c in (select * from table2) loop
    r:=replace(r, c.previousValue, c.newValue);
  end loop;
  return r;

and use it like this:

select replaceTable2(value) from table1;