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);
        }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM