看这个例子来做批量插入,我假设使用相同的逻辑将适用于更新。我尝试了以下操作以查看它是否有效,但它没有:
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();
这不适用于更新吗?有没有办法像我链接的示例中的批量插入一样轻松地进行批量更新?