简体   繁体   中英

Passing Array parameter from C# to Oracle collection type of table

I have declare a collection Table and record in PLSQL Specification.

  type loan_recov_rec is record(v_prncpl_ed_cd number(3),v_prncpl_recov number (7),v_int_ed_cd number(3), v_int_recov,number(5)); type loan_recov_tbl is table of loan_recov_rec index by binary_integer; 

procedure pr_final_settlement(v_loan_recov_tbl in loan_recov_tbl);

So, I pass the Array parameter from C# page

 cmd.ArrayBindCount = v_loan_recov_tbl.Length;
                Oracle.DataAccess.Client.OracleParameter P_loan_recov = new Oracle.DataAccess.Client.OracleParameter("v_loan_recov_tbl", Oracle.DataAccess.Client.OracleDbType.Int32);
P_loan_recov.Direction = ParameterDirection.Input;

P_loan_recov.CollectionType = Oracle.DataAccess.Client.OracleCollectionType.PLSQLAssociativeArray;
P_loan_recov.Value = v_loan_recov_tbl;
cmd.Parameters.Add(P_loan_recov);

using above code it not works it get's error Unable to cast object of type 'System.Int32' to type 'System.Array'. v_loan_recov_tbl is an Array Parameter. Unable to cast object of type 'System.Int32' to type 'System.Array'. v_loan_recov_tbl is an Array Parameter. Hear,I am using datatype as OracleDbType.Int32 is it right or i have to decler other data type.I declare Input parameter in Procedure as Table

I see two issues. First you are working with a PL/SQL-defined record type and not an SQL-defined object type. ODAC wants SQL-defined object types. Second, assuming you had all the proper SQL-defined object types and C# custom types defined, there's an excellent example of c# code to work with array binding in the ODP.NET software stack on your machine: %ODAC_HOME%\\odp.net\\samples\\4\\AssocArray.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM