With reference to Oracle: Variable number of parameters to a stored procedure
I have s stored procedure to insert multiple Users into a User table. The table is defi
After many false starts, this post here saved my bacon (binding to a UDT of TABLE OF VARCHAR2(100)
).
Salient points
varchar2(100)
)
IOracleCustomType
and INullable
interfaces. string[]
), and the property must be marked with the OracleArrayMapping
attribute.IOracleArrayTypeFactory
, IOracleCustomTypeFactory
interfaces. It needs the following methods
OracleCustomTypeMapping("SCHEMA.UDT_TYPE")
where SCHEMA.UDT_TYPE
matches your UDT type, viz CREATE TYPE SCHEMA.UDT_TYPE AS TABLE OF VARCHAR2(100)
By comparison, the bind on the parameter is straightforward:
var oracleArray = new MyArrayStorageClass
{
Array = new string[] {"Hello", "World"}
};
command.CommandType = CommandType.StoredProcedure;
var param = new OracleParameter("ip_parameterName", OracleDbType.Array)
{
// Case sensitive match to the `OracleCustomTypeMapping` on the factory
UdtTypeName = "SCHEMA.UDT_TYPE",
Value = oracleArray,
Direction = ParameterDirection.Input,
};
command.Parameters.Add(param);