title: How can I update data in CLOB fields using a >> prepared query << with ODP (Oracle.DataAccess)?
body: <p>I'm trying to execute a prepared sql query which updates <code>CLOB</code> fields in an Oracle 10g database (10.2.0.1).</p>
  
  <p>If I execute the following query from inside <code>SQL Developer</code> and supply the values for the placeholders, there is no prblem. If I however execute it through an <code>OracleCommand</code> (Oracle.DataAccess.dll, version 1.102.0.1 (I think), .NET Framework 3.5),
  I get the error message below. Note that we are not using the default oracle client as we require bulk insertion. The given ODP version and .NET Framework version are unfortunately a hard requirement and we may not change that.</p>
  
  <p><strong>Query:</strong></p>
  
  <pre><code>UPDATE master_table
  SET    description = :description,
         modification_notes = :modification_notes
  WHERE  master_id = :master_id;
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <blockquote>
    <p>ORA-00932: inconsistent datatypes: expected - got CLOB</p>
  </blockquote>
  
  <p><strong>Further Inormation:</strong></p>
  
  <p>Parameters are assigned as follows:</p>
  
  <pre><code>var param_description = new OracleParameter(":description", OracleDbType.Clob);
  param_description.Value = "Test";
  </code></pre>
  
  <p>I have tried the following things:</p>
  
  <ul>
  <li>insert <code>to_clob()</code> into the SQL query</li>
  <li>assign a <code>Oracle.DataAccess.Types.OracleClob</code> object to the parameter.</li>
  </ul>
  
  <p>I have also found the following description, but I would really want to be able to keep the prepared query.</p>
  
  <p><a href="http://www.codeproject.com/Questions/126179/How-to-insert-CLOB-field-in-Oracle-using-C" rel="noreferrer">How to insert CLOB field in Oracle using C#</a></p>
  
  <p>Is it possible to do this through a prepared query?</p>
  
  <p>I've attached a complete example which produces the error. <code>DESCRIPTION</code> and <code>MODIFICATION_NOTES</code> are two columns of type <code>CLOB</code> in the database.</p>
  
  <hr>
  
  <p><em>Input data:</em></p>
  
  <ul>
  <li>connection: <code>OracleConnection</code> to the database</li>
  <li>master_id: primary key to filter for</li>
  </ul>
  
  <p><em>Code:</em><br />
  <em>Disclaimer: I typed the following example by hand, there might be mistakes which are not in the actual code</em></p>
  
  <pre><code>var query = "UPDATE master_table " + 
              "SET description = :description " + 
              "    modification_notes = :modification_notes " +
              "WHERE master_id = :master_id";
  
  var param_master_id = new OracleParameter(":master_id", OracleDbType.Int64);
  param_master_id.Value = master_id;
  
  var param_description = new OracleParameter(":description", OracleDbType.Clob);
  param_description.Value = "Test1";
  
  var param_master_id = new OracleParameter(":modification_notes", OracleDbType.Clob);
  param_description.Value = "Test2";
  
  IDbCommand command = new OracleCommand(query, connection);
  command.parameters.Add(param_master_id);
  command.parameters.Add(param_description);
  command.parameters.Add(param_modification_notes);
  
  command.ExecuteNonQuery(); // this line throws an exception
  </code></pre>