【发布时间】:2020-07-07 00:12:29
【问题描述】:
我有以下代码将字符串表传递给名为 spTest 的 Oracle 存储过程:
using (OracleConnection oracleConnection = new OracleConnection(connectionString))
{
oracleConnection.Open();
OracleCommand oracleCommand = new OracleCommand();
oracleCommand.Parameters.Add(new OracleParameter
{
ParameterName = "eventids",
Direction = ParameterDirection.Input,
CollectionType = OracleCollectionType.PLSQLAssociativeArray,
Value = new string[] { "Test1", "Test2" },
Size = 2,
UdtTypeName = "T_STRING_TAB"
});
oracleCommand.Connection = oracleConnection;
oracleCommand.CommandText = "spTest";
oracleCommand.CommandType = CommandType.StoredProcedure;
using (OracleDataReader oracleDataReader = oracleCommand.ExecuteReader())
{
while (oracleDataReader.Read())
{
int fieldCount = oracleDataReader.FieldCount;
}
}
}
我在Oracle中已经定义了类型和存储过程如下:
create type T_STRING_TAB is table of varchar2(260) index
create or replace procedure spTest(eventids in T_STRING_TAB)
as
starteventid integer;
begin
starteventid := 1000000;
end;
当我运行代码时,我收到以下错误:
Oracle.ManagedDataAccess.Client.OracleException
HResult=0x80004005
Message=ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'SPTEST'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Source=Oracle Data Provider for .NET, Managed Driver
我正在使用 Oracle.ManagedDataAccess.dll 版本号 2.0.18.3。
有谁知道我做错了什么?
谢谢 伊恩
【问题讨论】:
标签: oracle