oracle批量导入数据
2015-10-22 17:06
411 查看
关键代码
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;
相关文章推荐
- oracle pl/sql之oracle函数
- Oracle分区表的使用
- oracle 10g rac asm上面的控制文件损坏既增加方法
- Oracle复制表和存储过程编写注意事项
- oracle pl/sql之在java中调用带有输入输出参数的oracle存储过程
- oracle 创建dblink
- oracle pl/sql之java中调用oracle有参存储过程
- oracle pl/sql之在java中调用无参的oracle存储过程
- oracle 10g 开归档后的RMAN备份试验
- Oracle AP Invoice APIs
- ORACLE禁用启用触发器
- Oracle 日期周详解以及周开始结束时间计算
- oracle 统计分析函数
- Oracle 数据迁移
- Oracle RMAN的参数
- oracle pl/sql之oracle存储过程
- ORACLE 过滤重复值SQL语句
- oracle pl/sql之使用游标变量更新数据库
- OCI调用oracle入门程序
- Oracle常用的OCI函数