简体   繁体   中英

Oracle.ManagedDataAccess.Core 3.21.61 using UDT Oracle 11g with c# .net 6

I'm currently working on upgrading code from .NET 4.5.1 to .NET 6. Currently working on database functionality. In .NET 4.5.1, I regularly used Oracle UDT as both input and output parameters without issue. However, for the life of me I can't get it to work on .NET 6. I'm using an Oracle 11g database, and I'm kind of thinking/hoping that the database version is the issue since there is an Oracle database upgrade planned in the coming months. Otherwise, I might have to delay the upgrade.

I think my code is pretty straight forward. The UDTTypes are defined in Oracle (and working in .NET 4.5.1) Logically then, that shouldn't be the issue. Abbreviated, they look as follows

create or replace TYPE "WBH_PLATELIST" IS TABLE OF WBH_PLATEOBJ;

create or replace TYPE "WBH_PLATEOBJ" AS OBJECT 
(
    LPID                VARCHAR2(15 BYTE),
    ITEM                VARCHAR2(50 BYTE)
    ...
)

I have a package with a procedure with signature as below that works just fine.

PROCEDURE GetInventoryPlates( p_CustId    IN varchar2,
                              p_Plate     OUT WBH_PLATELIST);

I'm using Oracle.ManagedDataAccess.Core v.3.21.61. My C# code looks like

string packageProc = "WBH_DEVELOPMENT.GetInventoryPlates";

OracleParameter clientparam = new OracleParameter() 
{   ParameterName = "p_CustId",
    Direction = ParameterDirection.Input, 
    Value = "XZXXX" 
};
OracleParameter plateparam = new OracleParameter()
{
    ParameterName = "p_Plate",
    DbType = DbType.Object,
    OracleDbType = OracleDbType.Object,
    Direction = ParameterDirection.Output,
    UdtTypeName = "ALPS.WBH_PLATELIST",
};

try
{
    using (OracleConnection SqlCon = new OracleConnection(@"Data Source=x.x.x.x:xxx/test;User ID=xxx;Password=xxx"))
    {
        using (OracleCommand SqlCmd = new OracleCommand(packageProc, SqlCon))
        {
            if (paramList != null)
            {
                SqlCmd.BindByName = true;
                SqlCmd.Parameters.Add(clientparam);
                SqlCmd.Parameters.Add(plateparam);
            }
            SqlCmd.CommandType = CommandType.StoredProcedure;
            SqlCmd.Connection.Open();
            SqlCmd.ExecuteNonQuery();
        }
    }
}
catch (OracleException ex)
{
    string log = ex.Message;

}

Seems like no matter what I do, I get the following error as soon as the ExecuteNonQuery function is called.

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

Can someone please point me in the right direction? Thanks.

我现在不记得来源了,但我很确定,我在某处看到,你需要有至少 12.1 的 DB 版本才能将 UDT 与托管驱动程序(正常和“核心”)一起使用。

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