如何替换 ' 或使用 XMLELEMENT Oracle 时的任何特殊字符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23369574/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to replace ' or any special character in when using XMLELEMENT Oracle
提问by Raj A
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 &
我有以下查询。如何保持撇号 ( '
) 完好无损,而不是将其替换为&apos
还有其他字符我也想处理,例如&
SELECT RTRIM(xmlagg(XMLELEMENT(E,'I''m'||':')).extract('//text()'),':')
FROM dual;
Output:
输出:
I'm
Thanks.
谢谢。
回答by Nick Krasnov
You can make use of utl_i18npackage and unescape_reference()function in particular. Here is an example:
您可以特别使用utl_i18n包和unescape_reference()函数。下面是一个例子:
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;
Result:
结果:
RES
-------
I'm
回答by Toolkit
SELECT dbms_xmlgen.convert( xmlagg(XMLELEMENT(E,'I''m'
||':')).extract('//text()').getclobval() ,1)
FROM dual;
I'm:
我是: