Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Oracle TransactionScopeOption.Suppress is not working as expected.

Ruchita OzaDec 4 2023

Language - DotNet

Used sdk - Oracle.ManagedDataAccess.Client

Below is my code snippet.

using (TransactionScope scope = new TransactionScope(GetTransactionScopeOption(), GetTransactionOptions()))
{
using (OracleConnection connection = new OracleConnection(ConnectionString))
{
OpenConnection(connection);

              using (OracleCommand cmd = connection.CreateCommand())  
               {  
                   cmd.CommandTimeout = CommandTimeout;  
                   cmd.CommandType = System.Data.CommandType.Text ;  
                   cmd.CommandText = query.ToString();  
                   if (parameters != null)  
                       cmd.Parameters.AddRange(parameters.ToArray());  
                   rowsAffected = cmd.ExecuteNonQuery();  
                   scope.Complete();

                  connection.Close();  
               }

               query.Remove(0, query.Length);  
               numberOfInsertsPerformed = 0;  
           }

       }

Issue - Transactions required and required new is working but for suppress it is not working as expected.

If in batch I have 2 statements, one is correct and another contains an error.

Behaviour for suppress should be that the first statement gets executed but it is not working.

It would be great if you could help me. Thank you

Comments
Post Details
Added on Dec 4 2023
1 comment
811 views