Exemple #1
0
        protected override void DoExecuteBatch(IDbCommand ps)
        {
            if (currentBatch != null)
            {
                int arraySize = 0;
                countOfCommands = 0;

                log.Info("Executing batch");
                CheckReaders();
                Prepare(currentBatch);

                if (Factory.Settings.SqlStatementLogger.IsDebugEnabled)
                {
                    Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString());
                    currentBatchCommandsLog = new StringBuilder().AppendLine("Batch commands:");
                }

                foreach (IDataParameter currentParameter in currentBatch.Parameters)
                {
                    List <object> parameterValueArray = parameterValueListHashTable[currentParameter.ParameterName];
                    currentParameter.Value = parameterValueArray.ToArray();
                    arraySize = parameterValueArray.Count;
                }

                // setting the ArrayBindCount on the OracleCommand
                // this value is not a part of the ADO.NET API.
                // It's and ODP implementation, so it is being set by reflection
                SetObjectParam(currentBatch, "ArrayBindCount", arraySize);
                int rowsAffected;
                try
                {
                    rowsAffected = currentBatch.ExecuteNonQuery();
                }
                catch (DbException e)
                {
                    throw ADOExceptionHelper.Convert(Factory.SQLExceptionConverter, e, "could not execute batch command.");
                }

                Expectations.VerifyOutcomeBatched(totalExpectedRowsAffected, rowsAffected);

                totalExpectedRowsAffected = 0;
                currentBatch = null;
                parameterValueListHashTable = null;
            }
        }
Exemple #2
0
        protected override void DoExecuteBatch(IDbCommand ps)
        {
            log.DebugFormat("Executing batch");
            CheckReaders();
            Prepare(currentBatch.BatchCommand);
            if (Factory.Settings.SqlStatementLogger.IsDebugEnabled)
            {
                Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString());
                currentBatchCommandsLog = new StringBuilder().AppendLine("Batch commands:");
            }

            int rowsAffected = currentBatch.ExecuteNonQuery();

            Expectations.VerifyOutcomeBatched(totalExpectedRowsAffected, rowsAffected);

            currentBatch.Dispose();
            totalExpectedRowsAffected = 0;
            currentBatch = new SqlClientSqlCommandSet();
        }
Exemple #3
0
        protected override void DoExecuteBatch(IDbCommand ps)
        {
            if (_currentBatch == null)
            {
                return;
            }

            _commandCount = 0;

            Log.Info("Executing batch");
            CheckReaders();

            AppendInsertsToCmd();

            var commandText = _batchCommand.ToString();

            _currentBatch.CommandText = commandText;

            LogCommand(_currentBatch);

            Prepare(_currentBatch);

            int rowsAffected;

            try {
                rowsAffected = _currentBatch.ExecuteNonQuery();
            } catch (Exception e) {
                Log.Error("Error executing batch.", e);
                throw;
            }

            Expectations.VerifyOutcomeBatched(_totalExpectedRowsAffected, rowsAffected);

            _totalExpectedRowsAffected = 0;
            _currentBatch     = null;
            _batchCommand     = null;
            _parameterCounter = 0;
        }