I have a custom type and stored procedure defined as follows:
CREATE OR REPLACE TYPE GuidArray is varray(1000) of RAW(32);
/
CREATE OR REPLACE
PROCEDURE BulkInsertTempItemGuid
(
ItemGuidList IN GuidArray default null
) AS
BEGIN
--
-- procedure body here
--
END;
/
I'm attempting to call this stored procedure in Oracle's ODP .NET from a c# application. I seem to be failling to set up my OracleParameter
correctly, as Oracle is telling me that I am not sending it the correct parameter set. I'm setting the CollectionType, OracleDbType, and Value as follows. parameters
is an OracleParameter
and arrangedGuidList
is an IEnumerable<Guid>
.
parameter.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
parameter.OracleDbType = OracleDbType.Raw;
parameter.Value = arrangedGuidList.ToArray();
Exception:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'BulkInsertTempItemGuid'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
When calling a stored procedure once with an array (rather than calling a procedure that takes atomic items, and calling it multiple times), you must set the OracleDbType as Array. The value gets set to the underlying data structured, as specified in a custom oracle datatype class. In this case, it is a byte[][].
I then defined my Oracle custom types. See here for an example. I adapted the SimpleVarray / SimpleVarrayFactory classes, but have them work with Byte[][].
The key part of the factory class is that the Custom Type mapping must match the parameter's UdtTypeName property, and be all caps. It seems like that the OracleCustomTypeMapping causes ODAC to bind at runtime the custom type specified in to the parameter and build the GuidArray class somewhere under the hood via the ToCustomObject / FromCustomObject methods.
-