title: How to change character set of the XMLTYPE variable?
body: <p>I'm currently having non-utf-8 DB but I need to produce XMLType variable with utf-8 encoding. I'm having a workaround but there seems to be bug in the Oracle, see the following link: 
  <a href="https://forums.oracle.com/forums/thread.jspa?messageID=10238641" rel="nofollow"> https://forums.oracle.com/forums/thread.jspa?messageID=10238641</a></p>
  
  <p>...and Oracle Support bug: 7698684</p>
  
  <p>The bug causes random </p>
  
  <pre><code>ORA-1482: unsupported character set
  ORA-6512: at "SYS.XMLTYPE", line 107
  </code></pre>
  
  <p>First of all I'm getting XMLType with dbms_xmlgen package. That XMLType is encoded with DB character set. </p>
  
  <p>To convert it to utf-8 character set I do like this:</p>
  
  <ul>
  <li>I convert XMLType variable to BLOB variable with getBlobVal method using NLS_CHARSET_ID
  ('UTF8') as parameter</li>
  <li>I convert BLOB variable back to XMLType with XMLType constructor method using BLOB variable as first parameter and NLS_CHARSET_ID
  ('UTF8') as second parameter. <strong>This causes random error :(</strong></li>
  </ul>
  
  <p>Does anybody know any alternative solution for this?</p>
  
  <pre><code>  l_xml   := dbms_xmlgen.getXMLType(l_ctx);
    l_xml_b := l_xml.getBlobVal(C_UTF8_CHARSET_ID);
    l_xml   := XMLType(l_xml_b, C_UTF8_CHARSET_ID);
  </code></pre>