title: Why isn't OraOLEDB's Statement Caching feature like JDBC's PreparedStatement?
body: <p>According to the Oracle 12c documentation, <a href="https://docs.oracle.com/cd/E47955_01/win.121/e18594/using.htm#BABCHCDD" rel="nofollow">https://docs.oracle.com/cd/E47955_01/win.121/e18594/using.htm#BABCHCDD</a>, the Statement Caching feature eliminates the need to parse a SQL statement every time it's executed. But when I view the trace file created by the assumptive sscce, I see this pattern:</p>
  
  <pre><code>PARSE
  EXEC
  FETCH
  PARSE
  EXEC
  FETCH
  PARSE
  EXEC
  FETCH
  ...
  PARSE
  EXEC
  FETCH
  </code></pre>
  
  <p>What I want to see is this pattern instead:</p>
  
  <pre><code>PARSE
  EXEC
  FETCH
  EXEC
  FETCH
  EXEC
  FETCH
  ...
  EXEC
  FETCH
  </code></pre>
  
  <p>Here's the code, with the connection description removed from the connectionString variable:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using Oracle.DataAccess.Client;
  namespace OracleTest {
     class Program {
        static void Main(string[] args) {
           string connectionString = "Statement Cache Size=75; Self Tuning=False;";
           OracleConnection connection = new OracleConnection(connectionString);
           connection.Open();
           Console.WriteLine(connection.StatementCacheSize);
           string commandString = "select dummy from dual where dummy = :d";
           OracleParameter parameter = new OracleParameter("d", OracleDbType.Varchar2);
           parameter.Value = "X";
           OracleCommand command = new OracleCommand(commandString);
           command.Connection = connection;
           command.AddToStatementCache = true;
           command.Parameters.Add(parameter);
           string trace = "begin dbms_monitor.session_trace_Enable(binds=&gt;true, waits=&gt;true); end;";
           OracleCommand traceCommand = new OracleCommand(trace);
           traceCommand.Connection = connection;
           traceCommand.ExecuteNonQuery();
           command.Prepare(); // docs say this is a no-op but I tried anyway
           for (int i=1; i&lt;= 10; i++) {
              OracleDataReader reader = command.ExecuteReader();
              while (reader.Read()) {
                 Console.WriteLine("a row");
              }
           }
        }
     }
  }
  </code></pre>
  
  <p>According to the docs, if you want full control over the feature, you have to do 3 things:</p>
  
  <ul>
  <li>declare the size of the statement cache</li>
  <li>set self tuning to false</li>
  <li>set the OracleCommand's AddToStatementCache member to true</li>
  </ul>
  
  <p>I believe I have satisfied all the requirements but the data provider is not doing what I want it to do.</p>