--Function to match multiple pattern and replace it with its particular mask.
create or replace function masking(in_event_desc in varchar2)
return varchar2
as
c_pattern other_table.pattern%type;
c_mask other_table.mask%type;
out_event_desc varchar2(4000) := in_event_desc;
--desc is like my name is XYZ and my phone no is 123456 and CC no is 789456.
cursor val is select pattern,mask from other_table;
--selects pattern like [0-9][0-9][0-9][0-9] and mask like #### plus all other various kind of patterns and their mask.
begin
open val;
loop
fetch val into c_pattern,c_mask;
exit when val%NOTFOUND;
out_event_desc := regexp_replace(out_event_desc,c_pattern,c_mask);
end loop;
close val;
return out_event_desc;
end;
how should I handle the ampersand (&) in a event description
--My name is XYZ & my phone no. is 123456.
--we cannot edit the event description
like 'My name is XYZ ' ||'&'||' my phone no. is 123456.'