title: XML Encoding in XMLTYPE column in Oracle DB
body: <p>I have a table created like this:</p>
  
  <pre><code>create table b (data timestamp, value XMLTYPE);
  </code></pre>
  
  <p>I run this script in TOAD 12.6 to store a XML in the table.</p>
  
  <pre><code>DECLARE
      lc_Soap         CLOB;
      lc_Request      CLOB;
      px_RequestXML   XMLTYPE
          := XMLTYPE ('&lt;test&gt;&lt;test1&gt;ABDDÇJJSõ&lt;/test1&gt;&lt;/test&gt;');
  BEGIN
      DELETE b;
  
      lc_Soap :=
          '&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
                 &lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
                    &lt;s:Header&gt;
                        &lt;h:AxisValues xmlns="urn:/microsoft/multichannelframework/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:h="urn:/microsoft/multichannelframework/"&gt;
                            &lt;User xmlns=""&gt;TEST&lt;/User&gt;
                        &lt;/h:AxisValues&gt;
                    &lt;/s:Header&gt;
                    &lt;s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
                        &lt;substr/&gt;
                    &lt;/s:Body&gt;
                &lt;/s:Envelope&gt;';
  
      lc_Request :=
          pkg_utils.replace_clob (lc_Soap,
                                  '&lt;substr/&gt;',
                                  xml_utils.XMLTypeToClob (px_RequestXML));
  
      px_RequestXML := XMLTYPE.createXML (lc_Request);
  
      INSERT INTO b
           VALUES (SYSTIMESTAMP, px_RequestXML);
  
      COMMIT;
  END;
  </code></pre>
  
  <p>When I try to see what is in the <code>VALUE</code> column I get this encoding <code>UTF-8</code></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
    &lt;s:Header&gt;
      &lt;h:AxisValues xmlns="urn:/microsoft/multichannelframework/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:h="urn:/microsoft/multichannelframework/"&gt;
        &lt;User xmlns=""&gt;TEST&lt;/User&gt;
      &lt;/h:AxisValues&gt;
    &lt;/s:Header&gt;
    &lt;s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
      &lt;test&gt;
        &lt;test1&gt;ABDDÃ‡JJSÃµ&lt;/test1&gt;
      &lt;/test&gt;
    &lt;/s:Body&gt;
  &lt;/s:Envelope&gt;
  </code></pre>
  
  <p>But this script was build to run in a different DB user or a in Oracle JOB. And in that cases, the encoding is different:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="WINDOWS-1252"?&gt;
  &lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
    &lt;s:Header&gt;
      &lt;h:AxisValues xmlns="urn:/microsoft/multichannelframework/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:h="urn:/microsoft/multichannelframework/"&gt;
        &lt;User xmlns=""&gt;TEST&lt;/User&gt;
      &lt;/h:AxisValues&gt;
    &lt;/s:Header&gt;
    &lt;s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
      &lt;test&gt;
        &lt;test1&gt;ABDDÇJJSõ&lt;/test1&gt;
      &lt;/test&gt;
    &lt;/s:Body&gt;
  &lt;/s:Envelope&gt;
  </code></pre>
  
  <p>The <code>NLS_CHARACTERSET</code> parameter for DB is WE8MSWIN1252.
  Why this append? And Who can I always store as UTF-8?</p>