使用ODP.NET的Oracle批量更新 [英] Oracle bulk updates using ODP.NET
本文介绍了使用ODP.NET的Oracle批量更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
看着<一href="http://dotnetslackers.com/articles/ado_net/BulkOperationsUsingOracleDataProviderForNETODPNET.aspx"相对=nofollow>这个例子的做批量插入,我以为用同样的逻辑会的工作进行更新。我想下面来看看它是否会工作,它不:
Looking at this example to do bulk inserts, I assumed using the same logic would work for updates. I tried to the following to see if it would work, and it does not:
string sql = "update TEST set NAME=:newName where NAME=:name";
connection.Open();
OracleCommand command = connection.CreateCommand();
command.CommandText = sql;
command.CommandType = System.Data.CommandType.Text;
command.BindByName = true;
command.ArrayBindCount = 5;
string[] originalName = { "Test1", "Test2", "Test3", "Test4", "Test5" };
string[] newName = { "New Test1", "New Test2", "New Test3", "New Test4", "New Test5" };
command.Parameters.Add(":newName", OracleDbType.Varchar2, originalName, System.Data.ParameterDirection.Input);
command.Parameters.Add(":name", OracleDbType.Varchar2, newName, System.Data.ParameterDirection.Input);
command.ExecuteNonQuery();
connection.Close();
这难道不是更新工作?有没有一种方法可以轻松地做批量插入类似如何在我联系的例子进行批量更新?
Does this not work for updates? Is there a way to easily do bulk updates similarly how the bulk inserts are performed in the example I linked?
推荐答案
原来,我有我的参数名称翻转。我花了永远可以找到它。
It turns out I had my parameter names flipped. Took me forever to find it.
这篇关于使用ODP.NET的Oracle批量更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文