title: Oracle Transaction Rollback doesn't work (Insert + ArrayBinding + Returning)
body: <p>One of my customers is facing a strange issue when Oracle Transaction.Rollback doesn't work.</p>
  
  <p>It appears the following thing must be used:</p>
  
  <ul>
  <li>Transaction or TransactionScope</li>
  <li>A PL/SQL (BEGIN END)</li>
  <li>ArrayBinding with at least 2 items</li>
  <li>The returning statement</li>
  </ul>
  
  <p>Both items are still inserted in the database even if a rollback have been called.</p>
  
  <p>Anyone have a clue why such behavior could happen?</p>
  
  <pre><code>using (var connection = new OracleConnection(ConfigurationManager.ConnectionStrings["OracleCodeFirstEntities"].ConnectionString))
  {
      connection.Open();
      var transaction = connection.BeginTransaction();
  
      using (var command = connection.CreateCommand())
      {
          command.BindByName = true;
  
          command.CommandText = @"
  BEGIN
  INSERT  INTO ""SYSTEM"".""EF_0104"" (""IntColumn"") VALUES(:P_0) RETURNING ""ID"" INTO :ZZZOUTPUT_0;
  END;
  ";
          int[] array = new int[] { 1, 2 };
  
          var param1 = command.CreateParameter();
          param1.ParameterName = "P_0";
          param1.DbType = DbType.Int32;
          param1.Value = array;
  
  
          var param2 = command.CreateParameter();
          param2.Direction = ParameterDirection.Output;
          param2.ParameterName = "ZZZOUTPUT_0";
          param2.DbType = DbType.Int32;
          param2.Value = array;
  
          command.Parameters.Add(param1);
          command.Parameters.Add(param2);
  
          command.ArrayBindCount = array.Length;
          command.ExecuteNonQuery();
      }
  
      transaction.Rollback();
  }
  </code></pre>
  
  <p><strong>Adding additional information</strong></p>
  
  <blockquote>
    <p>If there is an exception before transaction.Rollback()</p>
  </blockquote>
  
  <p>No, the rollback is done successfully without error.</p>
  
  <p>If I do it with only one item in the array, the rollback happen, if I do it without the returning statement, the rollback happen, but if this exact scenario happens, the rollback doesn't happen.</p>
  
  <blockquote>
    <p>which db provider are you using</p>
  </blockquote>
  
  <p>I have used Oracle.ManagedDataAccess (v4.121.2.0)</p>
  
  <blockquote>
    <p>Could the issue be that auto commit is enabled?</p>
  </blockquote>
  
  <p>I don't think this is the issue since if I remove one of the variants, the rollback works correctly.</p>
  
  <blockquote>
    <p>Have you turned on oracle tracing</p>
  </blockquote>
  
  <p>I will check this tomorrow; I'm not very familiar with Oracle right now.</p>