从 Microsoft 的 Oracle 驱动程序切换到 ODP.NET 版本 10.2.0.100。在过程中将数据类型更改为 OracleDBTypes 后,该过程使用 System.Data.OracleClient 完美运行,如果我们尝试传入超过 20 个参数,则该过程将失败。返回的错误是:
ORA-06550:第 1 行,第 7 列:PLS-00306:调用“ADD_TARP_EVENT”时参数的数量或类型错误 ORA-06550:第 1 行,第 7 列:PL/SQL:语句被忽略e
如果我们将参数数量减少到 20 以下,它就可以工作。这是一个已知的问题?
这里是创建参数的代码:
Shared Function CreateTarpEventCommand(ByVal aTarpEvent As TARPEventType) As OracleCommand
Dim cmd As New OracleCommand
With aTarpEvent
cmd.Parameters.Add(New OracleParameter("I_facID_C", OracleDbType.Char)).Value = .FacilityShortName
cmd.Parameters.Add(New OracleParameter("I_facName_VC", OracleDbType.Varchar2)).Value = .FacilityLongName
cmd.Parameters.Add(New OracleParameter("I_client_VC", OracleDbType.Varchar2)).Value = .ComputerNameTarpIsRunningOn
cmd.Parameters.Add(New OracleParameter("I_TARP_Version_VC", OracleDbType.Varchar2)).Value = .TarpVersionNumber
cmd.Parameters.Add(New OracleParameter("I_NAS_Type_VC", OracleDbType.Varchar2)).Value = .FacilityNASSystemType
cmd.Parameters.Add(New OracleParameter("I_Aircraft1_Callsign_VC", OracleDbType.Varchar2)).Value = .Aircraft1Callsign
If .Aircraft1Type Is Nothing Then
cmd.Parameters.Add(New OracleParameter("I_Aircraft1_Type_VC", OracleDbType.Varchar2)).Value = .Aircraft1Type
End If
If .Aircraft1Category Is Nothing Then
cmd.Parameters.Add(New OracleParameter("I_Aircraft1_Cat_VC", OracleDbType.Varchar2)).Value = .Aircraft1Category
End If
cmd.Parameters.Add(New OracleParameter("I_Aircraft2_Callsign_VC", OracleDbType.Varchar2)).Value = .Aircraft2Callsign
If .Aircraft2Type Is Nothing Then
cmd.Parameters.Add(New OracleParameter("I_Aircraft2_Type_VC", OracleDbType.Varchar2)).Value = .Aircraft2Type
End If
If .Aircraft2Category Is Nothing Then
cmd.Parameters.Add(New OracleParameter("I_Aircraft2_Cat_VC", OracleDbType.Varchar2)).Value = .Aircraft2Category
End If
If .SensorShortName Is Nothing Then
cmd.Parameters.Add(New OracleParameter("I_Sensor_Name_VC", OracleDbType.Varchar2)).Value = .SensorShortName
End If
If .TarpConfigurationName Is Nothing Then
cmd.Parameters.Add(New OracleParameter("I_TARP_Config_Name_VC", OracleDbType.Varchar2)).Value = .TarpConfigurationName
End If
If .EntryCreatorID Is Nothing Then
cmd.Parameters.Add(New OracleParameter("I_Create_VC", OracleDbType.Varchar2)).Value = .EntryCreatorID
End If
If .LogAction Is Nothing Then
cmd.Parameters.Add(New OracleParameter("I_Log_Action_VC", OracleDbType.Varchar2)).Value = .LogAction
End If
cmd.Parameters.Add(New OracleParameter("I_TARP_Mode_VC", OracleDbType.Varchar2)).Value = .TarpOperatingMode
cmd.Parameters.Add(New OracleParameter("I_Min_Loss_N", OracleDbType.Decimal)).Value = .ClosestMeasureOfLoSS
If .MapName Is Nothing Then
cmd.Parameters.Add(New OracleParameter("I_MAP_NAME_VC", OracleDbType.Varchar2)).Value = .MapName
End If
If .TarpConfigurationFileHash Is Nothing Then
cmd.Parameters.Add(New OracleParameter("I_CONFIG_HASH_VC", OracleDbType.Varchar2)).Value = .TarpConfigurationFileHash
End If
Dim aDate As OracleDate = CType(.LossEventsMessages(0).LossEventTime, System.DateTime)
cmd.Parameters.Add(New OracleParameter("I_FIRST_LOSS_EVENT_DATE", OracleDbType.Date)).Value = aDate
cmd.Parameters.Add(New OracleParameter("I_FIRST_LOSS_EVENT_MS_N", OracleDbType.Int32)).Value = .LossEventsMessages(0).LossEventMilliSeconds
If .ZippedMapFiles Is Nothing Then
cmd.Parameters.Add(New OracleParameter("I_Map_File_BL", OracleDbType.Blob)).Value = .ZippedMapFiles
End If
cmd.Parameters.Add(New OracleParameter("I_TARP_Package_BL", OracleDbType.Blob)).Value = .ZippedTarpPackageWithoutMaps
cmd.Parameters.Add(New OracleParameter("rs_RESULTS", OracleDbType.RefCursor)).Direction = ParameterDirection.Output
End With
Return cmd
End Function
这是执行该过程的代码:
Dim workingDataSet As New DataSet
Dim oracleConnection As New OracleConnection
Dim cmd As New OracleCommand
Dim oracleDataAdapter As New OracleDataAdapter
Try
Using oracleConnection
oracleConnection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("MasterConnectionODT")
cmd = HelperDB.CreateTarpEventCommand(TarpEvent)
cmd.Connection = oracleConnection
cmd.CommandText = "LOADER.ADD_TARP_EVENT"
cmd.CommandType = CommandType.StoredProcedure
Using oracleConnection
oracleConnection.Open()
Dim aTransation As OracleTransaction = oracleConnection.BeginTransaction(IsolationLevel.ReadCommitted)
Try
Using oracleDataAdapter
oracleDataAdapter = New OracleDataAdapter(cmd)
oracleDataAdapter.TableMappings.Add("Results", "rs_Max")
oracleDataAdapter.Fill(workingDataSet)
……