ORA-06550: Wrong number or type of arguments error | Calling Oracle Procedure with Table type IN parameter

强颜欢笑 提交于 2019-12-13 06:59:14

问题


We have one stored procedure in Oracle which accepts 1 IN parameter of type Table of Varchar2(50).

This is just sample Procedure to test how to pass IN parameter of type table. We are using PLSQLAssociativeArray type parameter to pass the array as IN parameter.

But it is throwing error:

ORA-06550: line 1, column 7: PLS-00306: wrong number or types of
arguments in call to 'SPGETMARKETPROMOTIONS' 
ORA-06550: line 1, column > 7: PL/SQL: Statement ignored

I have read mostly all the threads related to "ORA-06550: Wrong number or type of arguments error" but those were of no help.

Below are code snippets of Procedure and c# code used to call Procedure.

SP:

TAB_VAR_ARRAY TABLE OF VARCHAR2(50);

CREATE OR REPLACE PROCEDURE spGetMarketPromotions(promoid IN TAB_VAR_ARRAY) 
   IS
   BEGIN
    Update MKT set MKT_NM='UnitedKings' where MKT_CD='UK';
    END;
/

C# Code to Call this SP:

public static int test(List<string> pid)
        {
           // create and open connection object
            OracleConnection con = new OracleConnection(dbConnectionString);
            con.Open();

            // insert the new jobs into the jobs table
            // create command object and set attributes
            OracleCommand cmd = con.CreateCommand();
            cmd.CommandText = "spGetMarketPromotions";
            cmd.CommandType = CommandType.StoredProcedure;
            //cmd.ArrayBindCount = 2;
            cmd.BindByName = true;

            // create parameter objects for each parameter
            OracleParameter prid = new OracleParameter("promoid",               OracleDbType.Varchar2, ParameterDirection.Input);
            string[] list = { "sdafsad", "sdaf" };
            prid.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
            prid.Value = list;
            prid.Size = list.Length;

            cmd.Parameters.Add(prid);
            cmd.ExecuteNonQuery();

            return 1;
        }

Thanks for your help.

来源:https://stackoverflow.com/questions/26624284/ora-06550-wrong-number-or-type-of-arguments-error-calling-oracle-procedure-wi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!