在oracle raw输出参数的情况下应该是什么DbType

时间:2017-09-19 09:24:23

标签: c# oracle output-parameter dbtype

我正在使用C#.net 4.5.2并使用oracle DB。 我正在调用具有RAW输出参数(pPF)的函数:

FUNCTION GET_ACCESS_CONTEXT(pTId     IN NUMBER,
                            pUId       IN RAW,
                            pOId     IN RAW,
                            pFId     IN NUMBER,
                            pPF OUT RAW) RETURN RAW IS
  TYPE IDS_TP IS TABLE OF RAW(32);
  IDS IDS_TP;
BEGIN
  WITH BASE AS(
    select fl.*

      from t_folders_access fa
     inner join t_folders_links fl on fl.tenant_id = fa.tenant_id
                                  and fl.from_family_id = fa.family_id
                                  and fl.from_object_id = fa.object_id

     where fa.user_object_id = pUId
       and fa.tenant_id = pTId
       and fa.family_id = 12345
       and fl.deleted_object_flag = 0
       and fl.from_family_id = 12345
       and fl.family_id = 54321)
      select base.from_object_id BULK COLLECT
        INTO IDS
        from base
       start with base.family_id = 54321
              and base.to_family_id = 12345
              and base.to_object_id = pOId
      connect by nocycle prior base.from_object_id = base.to_object_id
             and base.family_id = 54321;


  IF IDS.LAST = 0 OR IDS is null or IDS.LAST is null THEN
    pPF := null;

    DBMS_OUTPUT.put_line ('return ' || pOId);
    return pOId;
  else
  DBMS_OUTPUT.put_line ('return ' || (IDS(IDS.FIRST)));
    pPF := IDS(IDS.FIRST);
    DBMS_OUTPUT.put_line ('return ' || IDS(IDS.LAST));
    return IDS(IDS.LAST);
  end if;
END;

在我的代码中,我用以下内容初始化输出参数:

DbType = DbType.Guid,
Size = 32,
Direction = ParameterDirection.Output,
ParameterName = "pPF"

当我从我的c#代码调用函数时,我得到了这个异常(当我使用相同的参数直接运行函数时没有异常......):" ORA-06502:PL / SQL:数字或值错误:原始变量长度太长", 从这一行:pPF := IDS(IDS.FIRST);IDS(IDS.FIRST)值为5093A4805899EB448F96BF9976F230AF。 我尝试了不同的DbTypes,但它没有帮助。

我做错了什么?

1 个答案:

答案 0 :(得分:0)

事实证明我们的系统中存在一个愚蠢的错误,但也许这可以帮助其他人: '方向'我的输出参数的属性值由' ParameterDirection.Input'运行。值。 当我修复它时,即使使用DBType也能正常工作:' Binary'和' String'。