Oracle批量插入在C#中的应用

public void SetUserReportResult(int[] reportId, bool isReceive, string result)
        {
            if (reportId == null)
                throw new ArgumentNullException("reportId");
            result = result.Left(80);
            string sql = "update msg_user_receive_report set isreceive=" + Convert.ToInt32(isReceive) + ",";
            if (!isReceive)
                sql += "ukey='0',";

            var resultParam = "null";
            if (result != null)
                resultParam = "'" + result.Replace("'", "''") + "'";

            sql += "result=" + resultParam + ",retrycount=retrycount+1,userreceivetime=sysdate where id=:reportId";
            Stopwatch watch;
            using (var connection = this.CreateConnection())
            {
                using (var command = connection.CreateCommand())
                {
                    var size = reportId.Length;
                    command.CommandText = sql;
                    command.ArrayBindCount = size;
                    command.Parameters.Add(new OracleParameter("reportId", OracleDbType.Int32) { Value = reportId });
                    connection.Open();
                    watch = Stopwatch.StartNew();
                    var c = command.ExecuteNonQuery();
                    watch.Stop();
                }
                connection.Close();
            }
            Trace.TraceInformation("Data.SetUserReportResult,watch=" + watch.ElapsedMilliseconds);
        }
原文地址:https://www.cnblogs.com/rengke2002/p/7462516.html