I have this C# code to call an Oracle stored procedure:
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.Parameters.Add("p_cursor", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
oracleCommand.Connection = oracleConnection;
oracleCommand.CommandText = "spTest";
oracleCommand.CommandType = CommandType.StoredProcedure;
using (OracleDataReader oracleDataReader = oracleCommand.ExecuteReader())
{
while (oracleDataReader.Read())
{
int fieldCount = oracleDataReader.FieldCount;
string s = oracleDataReader.GetString(0);
}
}
}
I have this in the database:
create or replace noneditionable package pp is
type t_string_tab is table of varchar2(260) index by binary_integer;
end;
create or replace noneditionable procedure sptest(
eventids in pp.t_string_tab,
p_cursor in out sys_refcursor)
as
begin
open p_cursor for
select p.column_value, 'Test1', 'Test2' from table(eventids) p;
end;
When I call this procedure from the code I get the following error:
Oracle.ManagedDataAccess.Client.OracleException:
ORA-21700: object does not exist or is marked for delete
ORA-06512: at "PPUSER.SPGETMETADATA", line 6 ORA-06512: at line 1'
This appears to be something to do with the T_STRING_TAB type not being accessible from the stored procedure?
I get this error even if I put the stored procedure in the PP package and call PP.spTest in the code. I also tried to use PP.T_STRING_TAB as the UdtTypeName in the code and this did not work. I cannot make the type global otherwise I get the following error:
PLS-00355: use of PL/SQL table not allowed in this context
Please note that I have added a new user so could it be to do with permissions?
I am not sure what I am doing wrong - I am not an Oracle expert!
This question follows on from How to pass an array of strings from C# to an Oracle stored procedure.