user3380298 user3380298 - 1 year ago 82
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

Answer Source

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;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download