如何更换&或在使用XMLELEMENT Oracle时的任何特殊字符 [英] How to replace ' or any special character in when using XMLELEMENT Oracle

查看:415
本文介绍了如何更换&或在使用XMLELEMENT Oracle时的任何特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下查询。如何保持撇号(')完好无损,并且不会被&'
替换其他字符也我想处理像&

I have the below query. How to keep the apostrophe (') intact and not getting it replaced by &apos There are other characters also I want to handle like &

SELECT RTRIM(xmlagg(XMLELEMENT(E,'I''m'||':')).extract('//text()'),':')
  FROM dual;

输出:

I'm

谢谢。

推荐答案

您可以使用 utl_i18n 软件包和 unescape_reference()函数。下面是一个示例:

You can make use of utl_i18n package and unescape_reference() function in particular. Here is an example:

clear screen;
column res format a7;

select utl_i18n.unescape_reference(
          rtrim(
               xmlagg( -- use of xmlagg() function in 
                       -- this situation seems to be unnecessary 
                       XMLELEMENT(E,'I''m'||':')
                      ).extract('//text()'),':'
                )
        ) as res
 from dual;

结果:

RES   
-------
I'm  

这篇关于如何更换&或在使用XMLELEMENT Oracle时的任何特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆