What should be the DbType in case of oracle raw output parameter

699 views Asked by At

I'm using C# .net 4.5.2 and working with oracle DB. I'm calling a function that have RAW output parameter (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;

In my code I initialize the output parameter with:

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

When I'm calling the function from my c# code,I get this exception (when I run the function directly with the same parameters there is no exception...): "ORA-06502: PL/SQL: numeric or value error: raw variable length too long", from this line: pPF := IDS(IDS.FIRST); while IDS(IDS.FIRST) value is 5093A4805899EB448F96BF9976F230AF. I tried different DbTypes but it didn't help.

What am I doing wrong?

1

There are 1 answers

0
Amir M On BEST ANSWER

It turned out there was a silly bug in our system, but maybe this can help others: The 'Direction' property value of my output parameter was run over by 'ParameterDirection.Input' value. When I fixed it it worked fine even with DBType:'Binary' and 'String'.