DataAction / AdoNetCore.AseClient

AdoNetCore.AseClient - a .NET Core DB Provider for SAP ASE
Apache License 2.0
106 stars 44 forks source link

Arithmetic overflow during implicit conversion of NUMERIC value '2819.0444' to a NUMERIC field . #173

Closed bbarry closed 4 years ago

bbarry commented 4 years ago

When using decimal output parameters and calling a stored procedure, we are getting various scale and precision errors depending on the value of the stored procedure.

Example procedure:

CREATE PROCEDURE dbo.Test184(@TotalValue numeric(18,4) = 0 output)
AS    
set @TotalValue = 2819.0444

C# to reproduce issue:

using var connection = AseClientFactory.Instance.CreateConnection();
connection.ConnectionString = Constants.ConnectionString;
connection.Open();
var cmd = connection.CreateCommand();
cmd.CommandText = "Test184";
cmd.CommandType = CommandType.StoredProcedure;
var total = new AseParameter()
{
    ParameterName = "@TotalValue",
    AseDbType = AseDbType.Decimal,
    Direction = ParameterDirection.Output,
    Precision = 18,
    Scale = 4,
};
cmd.Parameters.Add(total);

cmd.ExecuteNonQuery();

Expected: no errors

Actual: AdoNetCore.AseClient.AseException : Arithmetic overflow during implicit conversion of NUMERIC value '2819.0444' to a NUMERIC field .

.Net Core 3.1 or .Net Framework 4.8

AdoNetCore.AseClient 0.16.0

SAP ASE 16 PL07, also happens against PL03 (these are the versions of ASE I have connections to); similar code on .net framework works with Sybase.AdoNet4.AseClient.dll (testing with 16.0.3.0)

ryan-payet-wcc commented 4 years ago

I had a similar issue with an output parameter. I got it working using DbType = DbType.Int64 example new AseParameter("@batch_posfix", AseDbType.Numeric, 10) { Direction = ParameterDirection.Output, Scale = 10, Precision = 0, DbType = DbType.Int64 }

bbarry commented 4 years ago

In our case we have this working with the currency type but it seems like there is a problem with output parameters that have variable sizes?