This is a migrated thread and some comments may be shown as answers.

Problem with Store Procedure Decimal Output Parameter

3 Answers 748 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Rob
Top achievements
Rank 1
Rob asked on 12 Feb 2014, 04:53 AM

I've run into an issue when using a stored procedure that contains OUTPUT parameters of a decimal (or money) data type...it appears the value is getting converted to an integer and removing any decimal places (although it does round as per a convert)

Here is a simple SP that I used for testing:

CREATE PROCEDURE [dbo].[usp_Telerik_Test]
    @curTestAmount  DECIMAL(18,2) OUTPUT
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
 
    SET @curTestAmount = 1234.55
END
GO

Added to the Domain Model and executing it with the following:

decimal? curTestAmount = null;
this.CurrentDataSource.Usp_Telerik_Test(ref curTestAmount);

Returns a value of 1235

If I initialise the curTestAmount to 999999999999.99 then the result is returned successfully as 1234.55, interestingly if I initialise it to 1111.1 then the returned value is 1234.6...also if I initialise it to 111.11 an 'Error converting data type decimal to numeric.' error is thrown on the ExecuteNonQuery call in the EntitiesModel.cs!

Let me know if you would like any further information.

Kind Regards,

Rob

3 Answers, 1 is accepted

Sort by
0
Boris Georgiev
Telerik team
answered on 14 Feb 2014, 04:15 PM
Hi Rob,

First I would like to apologize for the inconvenience caused. It seems this is an issue on our side.

The problem occurs, because Telerik Data Access is getting the result shape precision and scale based on the input parameter, instead of the stored procedure. This is the reason when the parameter is 999999999999.99 - with precision 14 and scale 2, the result is the correct. When the parameter is null - 0 for precision and 0 for scale, the result is round to integer and when the result is 111.11 - 5 for precision and 2 for scale the exception is thrown, because the result has bigger precision.

If it is applicable for you, as a workaround, I would recommend you to pass a parameter with big enough precision and scale.

Find your Telerik Points updated for the new bug you have helped us identify.

We will notify you in this thread when a build containing the fix is available.

Regards,
Boris Georgiev
Telerik
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
0
Rob
Top achievements
Rank 1
answered on 24 Feb 2014, 02:50 AM
Thanks for the update Boris, I'll keep a look out for the update.

For your info, no Telerik points have appear in my account.

Cheers,

Rob.

0
Boris Georgiev
Telerik team
answered on 26 Feb 2014, 02:04 PM
Hello Rob,

Please accept my apologies for the omission. Your Telerik points have been updated.

Regards,
Boris Georgiev
Telerik
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
Tags
General Discussions
Asked by
Rob
Top achievements
Rank 1
Answers by
Boris Georgiev
Telerik team
Rob
Top achievements
Rank 1
Share this question
or