title: OracleCommand timeout
body: <p>ODP.NET <a href="http://docs.oracle.com/cd/B19306_01/win.102/b14307/OracleCommandClass.htm#DAFBGECA" rel="nofollow noreferrer">documentation for OracleCommand.CommandTimeout</a> says</p>
  <blockquote>
  <p>Default is 0 seconds, which enforces no time limit.</p>
  <p>When the specified timeout value expires before a command execution
  finishes, the command attempts to cancel. If cancellation is
  successful, an exception is thrown with the message of ORA-01013: user
  requested cancel of current operation. If the command executed in time
  without any errors, no exceptions are thrown.</p>
  <p>In a situation where multiple OracleCommand objects use the same
  connection, the timeout expiration on one of the OracleCommand objects
  may terminate any of the executions on the single connection. To make
  the timeout expiration of a OracleCommand cancel only its own command
  execution, simply use one OracleCommand for each connection if that
  OracleCommand sets the CommandTimeout property to a value greater than
  0.</p>
  </blockquote>
  <p>But a code like this works:</p>
  <pre><code>static void Main(string[] args)
  {
      OracleConnection conn = null;
      try
      {
          string connString =
              &quot;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=myOracleHost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=myServiceName)));User Id=system;Password=admin;Pooling = False;&quot;;
          string cmdString1 = &quot;UPDATE employee SET empname = 'temp1' where id = 1&quot;;
          string cmdString2 = &quot;Update employee set empname = 'temp2' where id = 2&quot;;
          conn = new OracleConnection(connString);
          var cmd1 = new OracleCommand(cmdString1, conn);
          cmd1.CommandTimeout = 30;
          var cmd2 = new OracleCommand(cmdString2, conn);
          cmd2.CommandTimeout = 30;
          conn.Open();
          try
          {
              //Locked the row with ID 1 with an uncommitted update operation outside this code
              cmd1.ExecuteNonQuery();
          }
          catch (Exception exception)
          {
              //Exception ORA-01013 Thrown as expected
          }
          try
          {
              //As per the documentation, this should not also work since this command object also uses the same connection as above and it timed out in the query above
              cmd2.ExecuteNonQuery();
              //But this still works fine. 
          }
          catch (Exception)
          {
              //no exception
          }
      }
      finally
      {
          conn.Close();
      }
  }
  </code></pre>
  <p>I am using the same <code>OracleConnection</code> object for both the command objects - <code>cmd1</code> and <code>cmd2</code>, and <code>cmd1</code> already timed out(as expected).
  But, per the documentation, <code>cmd2</code> also should not run. But it still runs without any exception and updates the other row properly.</p>