ODP传递整数数组

时间:2016-07-25 10:23:44

标签: c# oracle

这个问题让我抓狂。我试图将一个整数数组传递给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:   声明被忽略

我尝试过Int32Int64Decimal ...

1 个答案:

答案 0 :(得分:0)

因为看起来我不能将复杂类型用作表参数。我已将类型定义更改为:

0.0.0.0

现在可行。