Skip to content

OracleParameter array type #112

@deniscpereira

Description

@deniscpereira

Hi

I ran the stored-procedure example passing the OracleParameter parameter towards the input and I was successful.

When trying to send an array as a parameter I am not successful. Could you help me find the problem.

var arrayParam = new OracleParameter
{
     ParameterName = "list",
     Value = new long[2] { 1, 37 },
     OracleDbType = OracleDbType.Int64,
     Direction = ParameterDirection.Input,
     CollectionType = OracleCollectionType.PLSQLAssociativeArray // I need to add this
};

var idReturn = new OracleParameter
{
     ParameterName = "idNumberReturn",
     OracleDbType = OracleDbType.Int64,
     Direction = ParameterDirection.Output
};

string sql = "BEGIN PTEST(:list, :idNumberReturn); END;"
var teste = await _db.Database.ExecuteSqlRawAsync(sql, new object[] { arrayParam, idReturn });

Parameters de stored procedure

create PROCEDURE PTEST (
    ID_ARRAY        IN ARRAY_NUMBER_TYPE,
    ID_OUT             OUT NUMBER
)...

When I add CollectionType into parameter return error PLS-00306: incorrect number of argument types in the call to.

If you remove CollectionType in the parameter. System.InvalidCastException parameter return error: Cannot throw object of type 'System.Int64 []' to type 'System.IConvertible'.

What is the correct way to send array as parameter?

Use .net core and ef core 3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions