PL / SQL函数和regexp_replace

时间:2017-02-25 11:01:18

标签: sql oracle plsql

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

我应该如何处理事件描述中的&符号(&) - 我的名字是XYZ&我的电话号码是123456.
- 我们无法编辑事件描述 喜欢'我的名字是XYZ' ||'&安培;' ||'我的电话号码是123456。'

0 个答案:

没有答案