0
這個問題讓我瘋狂。我試圖將一個整數數組傳遞給ORACLE
函數,但沒有成功。ODP傳遞整數排列
我有一個表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
...