varchar2
我在 Oracle 中有一个存储过程,它接收可变数组类型的输入参数。该过程有效,如果您从 SQL 调用它,我需要从 C# 调用它。
我的脚本是这样的:
CREATE OR REPLACE PROCEDURE INTEGRATOR.PRC_TEST_PARAM_ARRAY (p_nros_moviles integrator.NROMOVIL_ARRAY) IS
BEGIN
FOR i IN 1..p_nros_moviles.count LOOP
IF p_nros_moviles(i) IS NOT NULL THEN
INSERT INTO INTEGRATOR.TEST_PARAM_ARRAY VALUES (p_nros_moviles(i));
END IF;
END LOOP;
END;
/
我的用户类型:
CREATE OR REPLACE TYPE INTEGRATOR.NROMOVIL_ARRAY AS
VARYING ARRAY(100) OF VARCHAR2(15);
/
我从 PLSQL 调用
DECLARE
v_array integrator.NROMOVIL_ARRAY;
BEGIN
v_array := integrator.NROMOVIL_ARRAY('9999999', '66666666');
integrator.prc_test_param_array(v_array);
END;
我从 c# 尝试这种方式
try
{
using (OracleConnection connection = new OracleConnection())
{
connection.ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)" +
"(HOST=10.10.10.10)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)" +
"(SID=PORTANODE)));User Id=user;Password=*****;";
using (OracleCommand cmd = new OracleCommand("INTEGRATOR.PRC_TEST_PARAM_ARRAY", connection))
{
cmd.CommandType = CommandType.StoredProcedure;
OracleParameter p = new OracleParameter();
p.ParameterName = "P_NROS_MOVILES";
p.OracleDbType = OracleDbType.Array;
p.Direction = ParameterDirection.Input;
p.UdtTypeName = "INTEGRATOR.NROMOVIL_ARRAY";
//p.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
p.Value = new string[] { "XXXX", "YYYY" };
cmd.Parameters.Add(p);
connection.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("Ejecutado");
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
有人可以指导我我需要进行更改才能使其正常工作