我试图通过C#执行以下oracle storedprocedure,但我得到异常“无效参数绑定”。我必须为“in_tab”传递数组值并执行sp。如何实现这个目标?
StoredProcedure的:
procedure CGN_SERVICE (in_tab VARRAY(200),out_cdetail OUT sys_refcursor,
out_code OUT NUMBER, out_msg OUT VARCHAR2)
用法:
using (UnitOfWorkScope scope = new UnitOfWorkScope(UnitOfWorkScopePurpose.Reading))
{
int[] mynums= new int[] { 1, 2, 3 };
var param = new OracleDynamicParameters();
param.Add("in_tab", mynums.ToArray(), dbType: OracleDbType.Array, direction: ParameterDirection.Input);
param.Add("out_detail", dbType: OracleDbType.RefCursor, direction: ParameterDirection.Output);
param.Add("out_code", dbType: OracleDbType.Int32, direction: ParameterDirection.Output);
param.Add("out_msg", dbType: OracleDbType.Varchar2, direction: ParameterDirection.Output, size: 200);
int res = scope.Connection.Execute("CGN_SERVICE", param, scope.Transaction, commandType: CommandType.StoredProcedure);
odr = param.Get<OracleRefCursor>("out_detail").GetDataReader();
}
答案 0 :(得分:0)
当数组已经是数组时,为什么要将mynums
转换为数组?
.ToArray()
在您的mynums
参数之后尝试一下。并尝试一下。