title: How to read a CLOB field into a C# variable?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/12574341/why-do-i-get-outofrange-exception-in-getordinal-function-of-this-clob-field">Why Do I get OutOfRange Exception in GetOrdinal Function of this CLOB field?</a>  </p>
  </blockquote>
  
  
  
  <pre><code>I need to read a CLOB field from an ORACLE table int a C# variable of type String. Does anyone know how to accomplish this task? 
  </code></pre>
  
  <p>This is what I have done but I am getting an IndexOutofRange when calculating the GetOrdinal of the field.  Thanks in advance.</p>
  
  <pre><code> public void ReadFunction(string FName, out string fContent) 
  { 
      OracleCommand command = _connection.CreateCommand(); 
      OracleTransaction transaction = _connection.BeginTransaction(); 
      command.Transaction = transaction; 
      command.CommandText = "SELECT TO_CLOB(TO_NCLOB(FUNCTION_SCRIPT)) FROM IS_FUNCTION where   FNAME=:fName "; 
      command.Parameters.Add("FName", OracleType.NVarChar).Value = FName; 
      OracleDataReader odr = command.ExecuteReader(); 
      int temp = odr.GetOrdinal("FUNCTION_SCRIPT"); 
      OracleLob myLob = odr.GetOracleLob(temp); 
      fContent = (String)myLob.Value; 
      odr.close(); 
  } 
  </code></pre>