问题
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