我需要打电话给 .Prepare 吗?
Do I need to call .Prepare?
假设我有以下代码:
Using conn As New OracleConnection(connString)
conn.Open()
Using oCommand As New OracleCommand("MERGE INTO...")
oCommand.BindByName = True
oCommand.Parameters.Add("param1",OracleDbType.Raw,value,ParameterDirection.Input)
oCommand.Parameters.Add("param2",OracleDbType.IntervalDS,value,ParameterDirection.Input)
// etc.
oCommand.Connection = conn
oCommand.Prepare()
oCommand.CommandType = CommandType.Text
oCommand.ExecuteNonQuery()
End Using
End Using
.Prepare 有必要吗?它在这种情况下有什么作用?
不,这不是必需的。根据 IDbCommand.Prepare 的文档:
The server automatically caches plans for reuse as necessary; therefore, there is no need to call this method directly in your client application.
调用 OracleCommand.Prepare 没有任何好处。这是一个NOOP。
https://docs.oracle.com/html/E10927_01/OracleCommandClass.htm
假设我有以下代码:
Using conn As New OracleConnection(connString)
conn.Open()
Using oCommand As New OracleCommand("MERGE INTO...")
oCommand.BindByName = True
oCommand.Parameters.Add("param1",OracleDbType.Raw,value,ParameterDirection.Input)
oCommand.Parameters.Add("param2",OracleDbType.IntervalDS,value,ParameterDirection.Input)
// etc.
oCommand.Connection = conn
oCommand.Prepare()
oCommand.CommandType = CommandType.Text
oCommand.ExecuteNonQuery()
End Using
End Using
.Prepare 有必要吗?它在这种情况下有什么作用?
不,这不是必需的。根据 IDbCommand.Prepare 的文档:
The server automatically caches plans for reuse as necessary; therefore, there is no need to call this method directly in your client application.
调用 OracleCommand.Prepare 没有任何好处。这是一个NOOP。
https://docs.oracle.com/html/E10927_01/OracleCommandClass.htm