【问题标题】:ORA-00604 error while batch insertion inside TransactionScope在 TransactionScope 中批量插入时出现 ORA-00604 错误
【发布时间】:2016-02-04 16:42:33
【问题描述】:

我正在尝试使用 TransactionScope 内的 ADO.NET 将 100k+ 项批量插入到我的 Oracle 数据库中。像这样:

using (TransactionScope transaction = new TransactionScope())
{
    while(/* Pagination logic - send insertion command on every 250 items */)
    {
        using (OracleCommand command = new OracleCommand(query, connection))
        {
            command.ArrayBindCount = 250;

            //Add parameters
            command.Parameters.Add(":BLAH", OracleDbType.Long);
            command.Parameters[0].Value = LUC.ToArray();

            command.ExecuteNonQuery(); //Error occurs here after N-times inside while
        }
    }
    transaction.Complete();
}

对于低于此 (10k-30k) 的项目,交易已成功完成。 但是对于更高的项目(如 100k),我得到 ORA-00604: error occurred at recursive SQL level %s

如果我完全删除 TransactionScope,任何项目大小都不会出现任何错误,它可以正常工作。

如何让 TransactionScope 处理大量项目?

【问题讨论】:

    标签: c# oracle ado.net transactionscope batch-insert


    【解决方案1】:

    原来是事务超时问题。

    增加超时后,我已成功插入列表:

    using (TransactionScope transaction = 
             new TransactionScope(TransactionScopeOption.Required, 
                     new TimeSpan(0, 30, 0))) //30 minute timeout limit
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-06-13
      • 2016-11-27
      • 2017-08-20
      • 1970-01-01
      • 2016-10-22
      • 1970-01-01
      • 1970-01-01
      • 2018-10-13
      相关资源
      最近更新 更多