我有一个需要 4 个输入的 PL/SQL 存储过程。这些输入之一是关联数组(Oracle 类型:PLS_INTEGER 索引的 VARCHAR2(1) 表)。
我想要一个 C# 程序,使用正确的输入(包括关联数组)调用此存储过程。
我将 ODP.net 11.2 与 Visual C# 2010 Express 和 Oracle 11gR2 结合使用。
我找不到任何关于如何从 C# 将数组传递到 pl/sql 过程的好示例。有人能给我举个例子吗?按照 Oracle 文档,我确实遇到错误,指出参数的数量或类型错误。
我的 C# 代码:
OracleCommand cmd = new OracleCommand("begin sdg_test.sdg_test2(:1); end;", conn);
OracleParameter Param1 = cmd.Parameters.Add("1", OracleDbType.Varchar2);
Param1.Direction = ParameterDirection.Input;
Param1.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
Param1.Value = new string[22] { "Y", "Y", "N", "Y", "N", "Y", "Y", "Y", "Y", "Y", "N", "Y", "N", "Y", "Y", "Y", "Y", "Y", "N", "Y", "N", "Y" };
Param1.Size = 22;
Param1.ArrayBindSize = new int[22] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
cmd.ExecuteNonQuery();
conn.Close();
conn.Dispose();
我的程序所做的只是记录一条消息。我只是想让这个概念发挥作用。