我想使用TRANSLATE
替换XMLAGG
中使用的字符串中的无效XML字符,而不是嵌套REPLACE
,因为需要替换大量字符:< / p>
select c.key,
cast( substr( xmlserialize( xmlagg( xmltext( concat( ' | ',
replace(replace(replace(replace(c.comment_text,chr(160),' '), chr(191),' '), chr(176),' '), chr(190),' ')
--translate(c.comment_text, ' ', chr(160)||chr(176)||chr(190)||chr(191))
) ) order by c.comment_date desc ) as clob ), 3, 4000 ) as varchar2) as sum_comment
from comments c
where c.comment_date > current_timestamp - 90
group by c.key
如果我在XMLAGG
之外运行,我可以看到TRANSLATE
和REPLACE
都删除了无效字符,但在XMLAGG
内我收到了错误我在使用TRANSLATE
:
An illegal XML character "#xA0" was found in an SQL/XML expression or function argument that begins with string " | A".