I have the following code to pass a table of strings to the Oracle stored procedure called spTest:
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;
}
}
}
I have defined the type and stored procedure as follows in 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;
When I run the code I get the following error:
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
I am using Oracle.ManagedDataAccess.dll version number 2.0.18.3.
Does anyone know what I am doing wrong?
Thanks Ian