Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6045387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:07:09+00:00 2026-05-23T07:07:09+00:00

I’m using a product that provides a database API based on Oracle functions and

  • 0

I’m using a product that provides a database API based on Oracle functions and I’m able to call functions via ODP.NET in general. However, I can’t figure out, how to call a function that includes a Ref Cursor as Out-parameter. All the samples I found so far either call a procedure with Out-parameter or a function with the Ref Cursor as return value. I tried to define the parameters similiarly, but keep getting the error that the wrong number or type of parameters is supplied.

Here is the function header (obviously obfuscated):

FUNCTION GetXYZ(
   uniqueId       IN   somepackage.Number_Type,
   resultItems    OUT  somepackage.Ref_Type)
   RETURN somepackage.Error_Type;

These are the type definitions in “somepackage”:

SUBTYPE Number_Type IS NUMBER(13);
TYPE Ref_Type IS REF CURSOR;
SUBTYPE Error_Type IS NUMBER;

And this is the code that I have tried:

string sql = "otherpackage.GetXYZ";
var getXYZCmd = OracleCommand oracleConnection.CreateCommand(sql);
getXYZCmd.CommandType = CommandType.StoredProcedure;

getXYZCmd.Parameters.Add("uniqueId", OracleDbType.Int32).Value = uniqueExplosionId;
getXYZCmd.Parameters.Add("resultItems", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
getXYZCmd.Parameters.Add("return_value", OracleDbType.Int32).Direction = ParameterDirection.ReturnValue;

The I tried the following different ways to call the function (of course only one at a time):

var result = getXYZCmd.ExecuteNonQuery();
var reader = getXYZCmd.ExecuteReader();
var scalarResult = getXYZCmd.ExecuteScalar();

But each of them fails with the error message:

Oracle.DataAccess.Client.OracleException: ORA-06550: line 1, column 15:
PLS-00306: wrong number or types of arguments in call to 'GETXYZ'
ORA-06550: line 1, column 15:
PLS-00306: wrong number or types of arguments in call to 'GETXYZ'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored.

So is it generally possible to call a function with a Ref Cursor as Out-parameter from C# with ODP.NET? I can call a function with the same structure with a Varchar2-Out-parameter instead of the Ref Cursor without problems…

Btw, I’m using ODP.NET version 2.112.2.0 from C#.NET 3.5 in Visual Studio 2008.

Thanks in advance for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:07:09+00:00Added an answer on May 23, 2026 at 7:07 am

    You sure can. There are a few gotchas to be wary of but here is a test case

    create or replace function testodpRefCursor(
                      uniqueId    IN NUMBER 
                     ,resultItems OUT NOCOPY SYS_REFCURSOR) RETURN NUMBER
                     IS
    
     BEGIN
          OPEN resultItems for select level from dual  connect by level < uniqueId ;
          return 1;
     END testodpRefCursor;
    
    1. I have found that
      functions likes to have the
      ReturnValue as THE FIRST param
      in the collection
    2. BindByName is by default FALSE, so it defaults to BIND BY POSITION

    Otherwise it is quite straight forward:

      OracleCommand cmd = new OracleCommand("TESTODPREFCURSOR", con);
      cmd.CommandType   = CommandType.StoredProcedure;
      cmd.BindByName = true;
      // Bind 
    
    
      OracleParameter oparam = cmd.Parameters.Add("ReturnValue", OracleDbType.Int64);
      oparam.Direction = ParameterDirection.ReturnValue ;       
    
      OracleParameter oparam0 = cmd.Parameters.Add("uniqueId", OracleDbType.Int64);
      oparam0.Value = 5 ;
      oparam0.Direction = ParameterDirection.Input;
    
      OracleParameter oparam1 = cmd.Parameters.Add("resultItems", OracleDbType.RefCursor);
      oparam1.Direction = ParameterDirection.Output;
    
    
    
    
      // Execute command
      OracleDataReader reader;
      try
      {
        reader = cmd.ExecuteReader();
    
        while(reader.Read() ){
            Console.WriteLine("level: {0}", reader.GetDecimal(0));  
        }
    
      } ...
    

    Now for more samples go to your Oracle Home directory and look @ the Ref cursor samples in ODP.NET

    for instance:
    %oracle client home%\odp.net\samples\4\RefCursor

    hth

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am using Paperclip to handle profile photo uploads in my app. They upload
In order to apply a triggered animation to all ToolTip s in my app,
I want use html5's new tag to play a wav file (currently only supported
I want to count how many characters a certain string has in PHP, but
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.