Используя .net core, dapper, dapper.oracle и базу данных oracle12, я просто не могу успешно вызвать процедуру с вводом массива.Я использую вход для утверждения WHERE IN.
using Dapper;
using Dapper.Oracle;
using Oracle.ManagedDataAccess.Client;
...
OracleDynamicParameters parameters = new OracleDynamicParameters();
parameters.ArrayBindCount = 3;
//this causes error PLS-00306: wrong number or types of arguments
parameters.Add("in_num_arr", new int[] { 2,5,6 }, OracleMappingType.Int64, ParameterDirection.Input);
//this causes app to hang without error
//parameters.Add("in_num_arr", new int[] { 2,5,6 }, OracleMappingType.Int64, ParameterDirection.Input, 3, null, null, null, null, null, OracleMappingCollectionType.PLSQLAssociativeArray);
parameters.Add("out_refcur", OracleDbType.RefCursor, OracleMappingType.RefCursor, ParameterDirection.Output);
using (_dbConnection = new OracleConnection(_appSettings.ConnectionStrings.AppDB))
{
var result = await _dbConnection.QueryMultipleAsync("NUM_T_PACKAGE.NUM_T_PROCEDURE", parameters, commandType: CommandType.StoredProcedure);
return result.Read<OutputObject>().ToList(); ;
}
Пакет Oracle:
create or replace PACKAGE num_t_package AS
TYPE num_t is table of NUMBER index by BINARY_INTEGER;
PROCEDURE num_t_procedure(in_num_arr IN num_t, out_refcur OUT SYS_REFCURSOR);
END num_t_package;
CREATE OR REPLACE
PACKAGE BODY NUM_T_PACKAGE AS
PROCEDURE num_t_procedure(in_num_arr IN num_t, out_refcur OUT SYS_REFCURSOR) AS
BEGIN
OPEN out_refcur FOR
SELECT
name
FROM
p_table
WHERE id IN (SELECT * FROM TABLE(in_num_arr));
END num_t_procedure;
END NUM_T_PACKAGE;