• oracle批量导入数据


    关键代码

    OracleDataAdapter da=new OracleDataAdapter();
                    string sql_select = string.Format("select id,dt_date,dt_time,dt_hours from {0}", biao);
                    string sql_insert = string.Format("insert into {0} (id,dt_date,dt_time,dt_hours) values(:id,:dt_date,:dt_time,:dt_hours)", biao);
                    da.SelectCommand = new OracleCommand(sql_select, oraCon);
                    da.InsertCommand = new OracleCommand(sql_insert, oraCon);
                    da.InsertCommand.Parameters.Add(":id",OracleType.VarChar,32,"id");
                    da.InsertCommand.Parameters.Add(":dt_date",OracleType.Number,8,"dt_date");
                    da.InsertCommand.Parameters.Add(":dt_time",OracleType.Number,5,"dt_time");
                    da.InsertCommand.Parameters.Add(":dt_hours",OracleType.Number,5,"dt_hours");
                    da.InsertCommand.UpdatedRowSource = System.Data.UpdateRowSource.None;
                    da.UpdateBatchSize=0;
                    DataSet ds=new DataSet();
                    da.Fill(ds);
                    int dt_hours = -3;
                    #region 
                    for (int j = 0; j < 75/3;j++ )
                    {
                        dt_hours = dt_hours + 3;
                        for (int i = 0; i < 25600; i++)
                        {
                            Guid guid = System.Guid.NewGuid();
                            Object[] row = { guid, sjint, 8, dt_hours };
                            ds.Tables[0].Rows.Add(row);
                            if (i % 400 == 0)
                            {
                                da.Update(ds.Tables[0]);
                                ds.AcceptChanges();
                                ds.Tables[0].Clear();
                            }
                        }
                        da.Update(ds.Tables[0]);
                        ds.AcceptChanges();
                        ds.Tables[0].Clear();
                        dt_hours = -3;
                    }
                    for (int j = 0; j < 75 / 3; j++)
                    {
                        dt_hours = dt_hours + 3;
                        for (int i = 0; i < 25600; i++)
                        {
                            Guid guid = System.Guid.NewGuid();
                            Object[] row = { guid, sjint,20, dt_hours };
                            ds.Tables[0].Rows.Add(row);
                            if (i % 400 == 0)
                            {
                                da.Update(ds.Tables[0]);
                                ds.AcceptChanges();
                                ds.Tables[0].Clear();
                            }
                        }
                        da.Update(ds.Tables[0]);
                        ds.AcceptChanges();
                        ds.Tables[0].Clear();
                        dt_hours = -3;
                    }
                    #endregion 
                    da.Dispose();
                    ds.Dispose();
                    oraCon.Close();
                    this.button2.Enabled = true;
    

      

  • 相关阅读:
    register_shutdown_function
    字节转换
    考虑 PHP 5.0~5.6 各版本兼容性的 cURL 文件上传
    linux--svn checkout
    linux命令
    linux---mysql忘记密码
    array_merge函数的注意事项
    逻辑卷使用记录笔记
    系统设计时关于性能问题处理的几点心得
    SSH防暴力破解脚本
  • 原文地址:https://www.cnblogs.com/bobo-show/p/4901606.html
Copyright © 2020-2023  润新知