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

  • SEARCH
  • Home
  • 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 3334706
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:56:05+00:00 2026-05-17T23:56:05+00:00

I have an Oracle stored procedure which takes two parameters: a custom data type

  • 0

I have an Oracle stored procedure which takes two parameters: a custom data type and a string.

Calling the stored procedure in Oracle, I would do the following:

EXECUTE MY_STORED_PROCEDURE(MYTYPE_T(99, 231), 'mystring')

How can I execute this using C#? I understand that I need to setup the command to be a stored procedure, but how do I specify the first parameter as custom data type?

Update:

MYTYPE_T is TABLE OF NUMBER created via

CREATE OR REPLACE TYPE mytype_t AS TABLE OF NUMBER ; 
  • 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-17T23:56:06+00:00Added an answer on May 17, 2026 at 11:56 pm

    You won’t be able to do this easily with the deprecated System.Data.OracleClient
    but you can utilize oracle’s ODP with using UDTs. If that is not an option, I am unsure how you can do it via parameters in C# with System.Data.

    ODP does come with a lot of examples and there are examples in the above links.

    I am going to add some more links that will hopefully help:

    1. visual studio ODP index
    2. this shows you exactly how to
      utilize the ODT to create you custom
      class wrappers and call them
      (do
      note that this is midway through,
      they walk through using the tool to
      create the custom types above it in
      the example — this walkthrough is
      quite thorough and should get you
      directly where you need to be)
    3. Download: now this guy also
      installs sample files, this is
      another terrific example of exactly
      what you need to do: once installed
      goto [directory path you
      install]..\product\11.2.0\client_1\odp.net\samples\4\UDT\object1.cs

    It really pays to allow the ODT tools for Visual studio to create your classes for your UDTs for you (e.g. IOracleCustomType and such) . you can then go into them and amend them to suit your needs. then once all is said and done (snippet from object1.cs):

        Person p1   = new Person();
    p1.Name     = "John";
    p1.Address  = "Address1";
    p1.Age = 20;
    
    // Establish a connection to Oracle
    OracleConnection con = new OracleConnection(constr);
    con.Open();
    
    // Update Person object and insert it into a database table
    OracleCommand cmd = new OracleCommand(sql1, con);
    cmd.CommandType = CommandType.StoredProcedure;
    OracleParameter param1 = new OracleParameter();
    
    param1.OracleDbType   = OracleDbType.Object;
    param1.Direction      = ParameterDirection.InputOutput;
    
    // Note: The UdtTypeName is case-senstive
    param1.UdtTypeName     = "SCOTT.ODP_OBJ1_SAMPLE_PERSON_TYPE";   
    param1.Value           = p1;
    
    cmd.Parameters.Add(param1);
    

    also note that Person class must implement IOracleCustomType (which can be created by following the link in #2)

    /* Person Class
       An instance of a Person class represents an ODP_OBJ1_SAMPLE_PERSON_TYPE object
       A custom type must implement INullable and IOracleCustomType interfaces
    */
    public class Person : INullable, IOracleCustomType
    

    The above is for a full custom type, but you are after an associative array ODP binding:

    http://weblogs.asp.net/ricardoperes/archive/2009/05/14/odp-net-associative-arrays.aspx

    you’ll want to use

    param1.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
    

    and everything should fall into place

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

Sidebar

Related Questions

No related questions found

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.