Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

using record and table type variables in ODP.Net

PleiadianOct 17 2014 — edited Nov 6 2014

Hi,

I am a reasonably experienced pl/sql developer, but very new to odp.net.

We want to use odp.net to create soap/rest services for several existing oracle functions.

Some of these functions return record types or tables of record types, e.g.:

type my_result_rec is record(

  val1 number,

  val2 number );

type my_result_tab is table of my_result_rec;

function my_function(

  param1 in number,

  param2 in number

) return my_result_tab;

Is it possible to use these kind of functions in odp.net? What is the preferred way of interacting with custom data types?

Thank you very much in advance!

Rob

This post has been answered by Pleiadian on Nov 6 2014
Jump to Answer

Comments

Alex Keh-Oracle

There is no native ODP.NET record data type yet. It's possible to create you own UDT custom types and have Visual Studio auto-generate the .NET custom data type code that maps your DB custom types. This tutorial can guide you on how to do this:

https://apex.oracle.com/pls/apex/f?p=44785:24:114147835440746:::24:P24_CONTENT_ID,P24_PROD_SECTION_GRP_ID,P24_PREV_PAGE:…

Christian.Shay -Oracle

This lack of support to bind to PL/SQL records is generic, across all Oracle client interfaces, not just ODP.NET.

Typically people get around this by creating a "wrapper" PL/SQL stored proc that sits on top of the original proc and "explodes" each record into it's individual types. In the case of a table of records, you would need to use index-by tables (associative arrays) of scalar values, one index-by table for each component member of a record.

It might be more performant to ask the owner of the packages to rewrite the logic to natively do this rather than writing wrappers which introduce copying.

Pleiadian
Answer

Thanks a lot for your replies!

We've solved the issue by converting the de table of record type into a sys_refcursor.

The types are now defined globally (instead of in a package) and we wrote a wrapper around the original function:

create or replace type my_result_rec as object(

  val1 number,

  val2 number );

create or replace type my_result_tab is table of my_result_rec;

function my_function_wrapper(

    param1 in number,

    param2 in number

  ) return sys_refcursor is

    result sys_refcursor;

  begin

    open result for

      select * from table(my_function(param1,param2));

    return result;

  end;


Rob

Marked as Answer by Pleiadian · Sep 27 2020
1 - 3
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 4 2014
Added on Oct 17 2014
3 comments
3,832 views