Can an Oracle stored procedure that has a nested table parameter be called from ODP.NET?

后端 未结 2 1652
北恋
北恋 2020-12-20 03:14

I\'ve got a stored procedure that has a couple parameters that are nested tables.

CREATE TYPE FOO_ARRAY AS TABLE OF NUMBER;
CREATE TYPE BAR_ARRAY AS TABLE OF         


        
2条回答
  •  失恋的感觉
    2020-12-20 03:37

    I made it work this way:

    • Create a type in the database like "create or replace TYPE NT_LNG IS TABLE OF varchar(2);"
    • Create a Class implementing IOracleCustomType and INullable (SimpleStringArray)
    • Create a Class implementing IOracleCustomTypeFactory (SimpleStringArrayFactory). Mark it with this attribute "[OracleCustomTypeMappingAttribute("KNL.NT_LNG")]"

    and you pass the parameter like this:

     SimpleStringArray sa1 = new SimpleStringArray();
     sa1.Array = new String[]{"aaa","bbb"};
     OracleParameter param = new OracleParameter("p_lngsrc", OracleDbType.Array, sa1, ParameterDirection.Input);
     param.UdtTypeName = "KNL.NT_LNG";
    

    Good Luck

提交回复
热议问题