title: How do I insert more than 4000 characters into XmlType using OracleClientFactory?
body: <p>I am trying to insert a chunk of Xml that is larger than 4000 characters into an XmlType field in an Oracle table. </p>
  
  <p>Originally my code worked like this:</p>
  
  <pre><code>DbParameter parameter = new DbParameter;
  parameter = clientFactory.CreateParameter(":p_xml_data", DbType.AnsiString, messageToLog.Length, ParameterDirection.Input, messageToLog);
  </code></pre>
  
  <p>However as soon as I started trying to insert Xml blocks larger than 4000 bytes I got:</p>
  
  <pre><code>ORA-01461: can bind a LONG value only for insert into a LONG column
  </code></pre>
  
  <p>This is the same issue as this question <a href="https://stackoverflow.com/questions/2508987/insert-xml-with-more-than-4000-characters-into-a-oracle-xmltype-column">2508987/insert-xml-with-more-than-4000-characters-into-a-oracle-xmltype-column</a>, however I do not have DbType.Clob as an option (it doesn't exist). </p>
  
  <p>Next I tried changing the type to DbType.Object, hoping it would just convert it to whatever it needed, but I get this message:</p>
  
  <pre><code>Cannot bind type System.String as Blob
  </code></pre>
  
  <p>Then I tried using DbType.XML, I modified my code to move the messageToLog into a SqlXml object:</p>
  
  <pre><code>SqlXml sx;
  XmlDocument xmlDoc = new XmlDocument();
  xmlDoc.LoadXml(messageToLog);
  using (XmlNodeReader xnr = new XmlNodeReader(xmlDoc))
  {
      sx = new SqlXml(xnr);
  }
  </code></pre>
  
  <p>And changed the parameter accordingly:</p>
  
  <pre><code>parameter = providerFactory.CreateParameter(":p_xml_data", DbType.Xml, messageToLog.Length, ParameterDirection.Input, sx);
  </code></pre>
  
  <p>Now I get:</p>
  
  <pre><code>Value is not valid for DbType: Xml
  </code></pre>
  
  <p>Truely I just want to store larger blocks of XML in my column. </p>