Page 1 of 1

Parameter.Size inference doesn't work on ExecuteArray with enumeration

Posted: Mon 23 Sep 2013 11:11
by klaus linzner
Hi,
When an enum is set as value of a Parameter it works as long as it's set directly on the param and the command is executed via ExecuteNonQuery.
But if you want to execute it via ExecuteArray, the objects value is taken correctly but its size is not infered.

Code: Select all

public enum SomeEnum
{
    SomeValue
}

[TestMethod]
public void EnumSizeInferenceTest()
{
const string sqlProcedure = "EnumBindingTest";
    using (OracleConnection connection = new OracleConnection(ConnectionString))
    {
        connection.Open();
        using (OracleCommand commandSingleInferenceWorks = connection.CreateCommand())
        {
            commandSingleInferenceWorks.CommandText = sqlProcedure;
            commandSingleInferenceWorks.CommandType = CommandType.StoredProcedure;
            OracleParameter pVarchar1 = new OracleParameter("P_VARCHAR1", OracleDbType.VarChar);
            pVarchar1.Value = SomeEnum.SomeValue;
            commandSingleInferenceWorks.Parameters.Add(pVarchar1);
            //size could be infered from the value
            commandSingleInferenceWorks.ExecuteNonQuery();
        }

        using (OracleCommand commandArrayInferenceWorksOnString = connection.CreateCommand())
        {
            commandArrayInferenceWorksOnString.CommandText = sqlProcedure;
            commandArrayInferenceWorksOnString.CommandType = CommandType.StoredProcedure;
            OracleParameter pVarchar1 = new OracleParameter("P_VARCHAR1", OracleDbType.VarChar);
            pVarchar1.Value = new object[] {"sAmeValue", SomeEnum.SomeValue};
            commandArrayInferenceWorksOnString.Parameters.Add(pVarchar1);
            //in this case: size was infered by the first string value.
            commandArrayInferenceWorksOnString.ExecuteArray(2);
        }

        using (OracleCommand commandManualSizeSetting = connection.CreateCommand())
        {
            commandManualSizeSetting.CommandText = sqlProcedure;
            commandManualSizeSetting.CommandType = CommandType.StoredProcedure;
            OracleParameter pVarchar1 = new OracleParameter("P_VARCHAR1", OracleDbType.VarChar);
            pVarchar1.Value = new object[] {SomeEnum.SomeValue};
            pVarchar1.Size = 9;
            commandManualSizeSetting.Parameters.Add(pVarchar1);
            //size doesn't need to be infered as it was set manually
            commandManualSizeSetting.ExecuteArray(1);
        }

        using (OracleCommand commandArraySizeInferenceFails = connection.CreateCommand())
        {
            commandArraySizeInferenceFails.CommandText = sqlProcedure;
            commandArraySizeInferenceFails.CommandType = CommandType.StoredProcedure;
            OracleParameter pVarchar1 = new OracleParameter("P_VARCHAR1", OracleDbType.VarChar);
            pVarchar1.Value = new object[] {SomeEnum.SomeValue};
            commandArraySizeInferenceFails.Parameters.Add(pVarchar1);
            commandArraySizeInferenceFails.ExecuteArray(1);
        }
    }
}
Here's the code for the SP as well

Code: Select all

CREATE OR REPLACE PROCEDURE EnumBindingTest (
    P_VARCHAR1 VARCHAR2
)
IS
BEGIN
    NULL;
END;
Tests were run with devart 7.8.287

Re: Parameter.Size inference doesn't work on ExecuteArray with enumeration

Posted: Wed 25 Sep 2013 15:12
by Pinturiccio
We have reproduced the issue. We will investigate it and post here about the results as soon as possible.

Re: Parameter.Size inference doesn't work on ExecuteArray with enumeration

Posted: Fri 27 Sep 2013 13:24
by Pinturiccio
We have fixed the bug with executing ExecuteArray for VarChar/NVarChar parameters with Size not specified explicitly, when the parameter Value contains an array, having only enum values. We will post here when the corresponding build of dotConnect for Oracle is available for download.

Re: Parameter.Size inference doesn't work on ExecuteArray with enumeration

Posted: Fri 18 Oct 2013 08:59
by Pinturiccio
New version of dotConnect for Oracle 8.0 is released!
It can be downloaded from http://www.devart.com/dotconnect/oracle/download.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?t=28131.