码迷,mamicode.com
首页 > 数据库 > 详细

PLSQL XML特殊字符转换

时间:2017-01-21 22:36:05      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:plsql 特殊字符

---特殊字符转换

  function process_xml(old_xml in varchar2) return varchar2 as

    new_xml varchar2(1000);

  begin

    select replace(old_xml, ‘<‘, ‘&lt;‘) into new_xml from dual;

    select replace(new_xml, ‘>‘, ‘&gt;‘) into new_xml from dual;

    select replace(new_xml, ‘&‘, ‘&amp;‘) into new_xml from dual;

    select replace(new_xml, ‘‘‘‘, ‘&apos;‘) into new_xml from dual;

    select replace(new_xml, ‘"‘, ‘&quot;‘) into new_xml from dual;

  

    SELECT regexp_replace(new_xml, ‘^(\W)*|(\W)*$‘, ‘‘)

      INTO new_xml

      FROM dual;

  

    return new_xml;

  exception

    when others then

      return ‘ERROR!‘;

  end process_xml;


PLSQL XML特殊字符转换

标签:plsql 特殊字符

原文地址:http://9966064.blog.51cto.com/9956064/1893562

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!