Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace ' or any special character in when using 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;

Output:

I'm

Thanks.

like image 207
Rajiv A Avatar asked Apr 29 '14 15:04

Rajiv A


People also ask

How messy is window replacement?

If you are considering replacing your home windows, you may be wondering how much mess it will cause. The simple answer is yes; it can be a messy job. There will be dust that is likely to spread around your home during installation.

Do you install replacement windows from the inside or outside?

In colder climates, it is generally more efficient to install windows from the inside to be sealed against the cold air. However, installing windows from the outside is more common in warmer temperatures, as it allows for better airflow and cooling.


1 Answers

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;

Result:

RES   
-------
I'm  
like image 95
Nick Krasnov Avatar answered Sep 27 '22 02:09

Nick Krasnov