我正试图调用一个采用自定义数据类型
table of numbers
作为参数之一。
以下是类型的定义:
create type num_list as table of number;
以及程序的定义:
create or replace procedure my_procedure
(listofnumbers num_list,
v_value char)
is
begin
update my_table
set my_column = v_value
where my_row_id in (select column_value
from table(listofnumbers));
end;
使用odp.net和c,我声明如下:
var row_ids = new int[] { 1, 2 };
using (var oracleConn = new Oracle.DataAccess.Client.OracleConnection(myConnectionString))
{
oracleConn.Open();
var cmd = new Oracle.DataAccess.Client.OracleCommand("my_procedure", oracleConn);
cmd.CommandType = CommandType.StoredProcedure;
var param1 = new Oracle.DataAccess.Client.OracleParameter("listofnumbers", Oracle.DataAccess.Client.OracleDbType.Array, ParameterDirection.Input);
param1.CollectionType = Oracle.DataAccess.Client.OracleCollectionType.PLSQLAssociativeArray;
param1.UdtTypeName = "num_list";
param1.Value = row_ids;
cmd.Parameters.Add(param1);
var param2 = new Oracle.DataAccess.Client.OracleParameter("v_value ", Oracle.DataAccess.Client.OracleDbType.Char, ParameterDirection.Input);
param2.Value = "Y";
cmd.Parameters.Add(param2);
cmd.ExecuteNonQuery();
}
引发的异常说明:
无效的参数绑定参数
姓名:号码列表
定义参数时缺少哪些属性?