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 7641261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:52:42+00:00 2026-05-31T08:52:42+00:00

There’s numerous question and confusing docs on the subject, but no luck so far.

  • 0

There’s numerous question and confusing docs on the subject, but no luck so far.

I’ve the following PL/SQL stored procedure;

PROCEDURE PS_test(
  Liste1 Listcar,
  Liste2 Listcar,
  P_CURS_MESSAGE out CURSOR_REF_TYP
)

Where the type Listcar is the following:

TYPE Listcar IS VARRAY(100) OF VARCHAR2(50);

Here is what I’m trying so far:

string[] list = { "name1", "name1" };

OracleParameter oParam = (OracleParameter)myOracleCommand.CreateParameter();
oParam.ParameterName = "Liste1";
oParam.UdtTypeName = "LISTCAR";
oParam.Value = list;
oParam.Direction = ParameterDirection.Input;
myOracleCommand.Parameters.Add(oParam);

With the following error on the Value assignment:

Value does not fall within the expected range.

Tried to use the type varchr2, to set the ArrayBindSize and so on, but no luck so far.

I guess the interface IOracleArrayTypeFactory might play a role somewhere, but how?

  • 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-31T08:52:44+00:00Added an answer on May 31, 2026 at 8:52 am

    I haven’t used the udtType feature in ODP.NET, so I am not sure how to achieve your goal with this. However, to pass an array of string you don’t need it.

    Like the documentation you attached, you need to create a package contains your stored procedure, and takes an associative array (not VARRAY) as input parameter.

    For example:

    -- Create the table
    CREATE TABLE TBLTEST (testID NUMBER, name VARCHAR2(50));
    
    CREATE SEQUENCE seq_test
        MINVALUE 1
        START WITH 1
        INCREMENT BY 1
        NOCACHE;
    
    CREATE OR REPLACE PACKAGE pkgTestArrayBinding
    AS 
        -- Define an local scope associative array type called T_ASSOCIATIVE_ARRAY and make it as the type of input parameter
        TYPE T_ASSOCIATIVE_ARRAY IS TABLE OF VARCHAR(50) INDEX BY PLS_INTEGER;
        PROCEDURE TestArrayBinding(
            Param1 IN T_ASSOCIATIVE_ARRAY,
            Param2 IN T_ASSOCIATIVE_ARRAY);
    END pkgTestArrayBinding;
    /
    
    CREATE OR REPLACE PACKAGE BODY pkgTestArrayBinding
    AS
        PROCEDURE TestArrayBinding(
            Param1 IN  T_ASSOCIATIVE_ARRAY,
            Param2 IN  T_ASSOCIATIVE_ARRAY)
        AS
        BEGIN
            -- for all loop to insert them in a batch
            FORALL indx IN 1..Param1.COUNT
                INSERT INTO tblTest VALUES(seq_test.nextval, Param1(indx));
    
            FORALL indx IN 1..Param2.COUNT
                INSERT INTO tblTest VALUES(seq_test.nextval, Param2(indx));
        END TestArrayBinding;
    END pkgTestArrayBinding;
    /
    

    Now, run this code, put your own connection string.

    namespace Con1
    {
        using System;
        using System.Data;
    
        using Oracle.DataAccess.Client;
    
        /// <summary>
        /// The program.
        /// </summary>
        internal class Program
        {
            #region Methods
    
            /// <summary>
            /// The main.
            /// </summary>
            private static void Main()
            {
                var con = new OracleConnection { ConnectionString = "User Id=usr;Password=pass;Data Source=XE" };
    
                con.Open();
                Console.WriteLine("Connected to Oracle" + con.ServerVersion);
    
                // create command to run your package
                var cmd = new OracleCommand("BEGIN pkgTestArrayBinding.TestArrayBinding(:Param1, :Param2); END;", con);
    
                var param1 = cmd.Parameters.Add("Param1", OracleDbType.Varchar2);
                var param2 = cmd.Parameters.Add("Param2", OracleDbType.Varchar2);
    
                param1.Direction = ParameterDirection.Input;
                param2.Direction = ParameterDirection.Input;
    
                // Specify that we are binding PL/SQL Associative Array
                param1.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
                param2.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
    
                // Setup the values for PL/SQL Associative Array
                param1.Value = new[] { "First Element", "Second Element ", "Third Element_" };
                param2.Value = new[] { "Fourth Element", "Fifth Element ", "Sixth Element " };
    
                // Specify the maximum number of elements in the PL/SQL Associative Array
                // this should be your array size of your parameter Value.
                param1.Size = 3;
                param2.Size = 3;
    
                // Setup the ArrayBindSize for each elment in the array, 
                // it should be bigger than the original length of element to avoid truncation
                param1.ArrayBindSize = new[] { 13, 14, 13 };
    
                // Setup the ArrayBindSize for Param2
                param2.ArrayBindSize = new[] { 20, 20, 20 };
    
                // execute the cmd
                cmd.ExecuteNonQuery();
    
                // I am lazy to query the database table here, but you should get you data now.
                // watch what happened to element "Third Element_"
    
                // Close and Dispose OracleConnection object
                con.Close();
                con.Dispose();
                Console.WriteLine("Disconnected");
            }
    
            #endregion
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is previous little on the google on this subject other than people asking
There are numerous Agile software development methods. Which ones have you used in practice
There are numerous libraries providing Linq capabilities to C# code interacting with a MySql
There was a thread on this in comp.lang.javascript recently where victory was announced but
There are many tutorials that talk about deleting index.php from the url. But I
There must be a simple solution to this, but after 4 hours of browsing
There's a lot of reading on self referencing problems, but I can't seem to
There are things like f.call(...) f.apply(...) But then there's this (1, alert)('Zomg what is
There is this SQL Statement SELECT t1.Name ,Count(t2.SubID) Totals -- I don't know how
There are numerous places on the Internet, suggesting that it is easily achieved by

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.