这个问题把我逼疯了。我试图将一个整数数组传递给ORACLE函数,但没有成功。
我有一个带有列的表scada_stops_header:
1. ST_EVENTGROUPID NUMBER(15,0)
2. ST_CATEG NUMBER(6,0)
3. ST_SUBCATEG NUMBER(6,0)以下是包代码:
create or replace package scada as
....
type stopid_record is record(stop_id scada_stops_header.st_eventgroupid%type);
type stopid_table is table of stopid_record INDEX BY BINARY_INTEGER;
....
function stops_set(fids_table in stopid_table,
fcateg in scada_stops_header.st_categ%type,
fsubcateg in scada_stops_header.st_subcateg%type,
ferrmsg out nvarchar2) return number;下面是C#代码:
using (OracleCommand cmd = new OracleCommand("scada.stops_set", con))
{
cmd.CommandType = CommandType.StoredProcedure;
var pResult = new OracleParameter("return", OracleDbType.Int32);
pResult.Direction = ParameterDirection.ReturnValue;
var pIDs = new OracleParameter("fids_table", OracleDbType.Decimal);
pIDs.Direction = ParameterDirection.Input;
pIDs.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
pIDs.Value = stops.Stops;
var pCategory = new OracleParameter("fcateg", OracleDbType.Int32);
pCategory.Direction = ParameterDirection.Input;
pCategory.Value = stops.TypeID;
var pSubcategory = new OracleParameter("fsubcateg", OracleDbType.Int32);
pSubcategory.Direction = ParameterDirection.Input;
pSubcategory.Value = stops.SubtypeID;
var pError = new OracleParameter("ferrmsg", OracleDbType.NVarchar2, 500);
pError.Direction = ParameterDirection.Output;
cmd.Parameters.Add(pIDs);
cmd.Parameters.Add(pCategory);
cmd.Parameters.Add(pSubcategory);
cmd.Parameters.Add(pError);
cmd.Parameters.Add(pResult);
con.Open();
cmd.ExecuteNonQuery();
}我得到了例外:
Oracle.ManagedDataAccess.Client.OracleException (0x00001996):ORA-06550:第1行,第15栏: PLS-00306:调用'STOPS_SET‘ORA-06550的错误数目或参数类型:第1行,第7列: PL/SQL:忽略语句
我试过过Int32,Int64,Decimal.
发布于 2016-07-25 11:32:45
看起来,我不能使用复杂类型作为表参数。我已将类型定义更改为:
type stopid_table is table of
scada_stops_header.st_eventgroupid%type INDEX BY BINARY_INTEGER;现在起作用了。
https://stackoverflow.com/questions/38565227
复制相似问题