Are FMTBCD parameters (fully) supported?
Posted: Tue 20 Sep 2011 09:23
Hello,
I am experimenting with the DBExpress driver for MS SQL Server 5.01 and am having problems with numeric(m, n) parameters when m>14 and/or n>4
Problem 1
When n>4 it seems that inputparameter values are rounded to 4 decimals; this can even lead to an exception:
Project x raised exception class EMSError with message 'Error converting data type money to numeric.'
In this case the parameter is Numeric(6,5) and the value is 9.99999
When checking the SQL statement with SQL Profiler I see (something) like this:
declare @P2 varchar(67)
select @P2 = NULL
exec dbo.MyStoredProc $10.0000, @P2 output
select @P2
So the value is rounded to 10.0000 and now longer fits into numeric(6,5). (When I execute the above statement in SQL Server Management Studio, it gives the same error message)
Question 1:
Why is the money datatype/notation used for inputparameter, while the outputparameter is used as varchar (note the @P2 parameter is defined as numeric(6,5) in the stored procedure.
Can the inputparameter be forced to be also varchar and not be rounded to 4 decimals?
Note: when I use the standard DBExpress driver by Embarcadero (D2010), the inputparametervalues are set via varchar, so they are not rounded and have the correct numeric scale.
Problem 2:
When m>14 I get an exception
Project x raised exception class EInvalidOp with message 'Invalid floating point operation'
I guess this has to do with the rounding/manipulation of inputparameter values when the SQL statement is constructed
Question 2:
How can I prevent this exception?
I am experimenting with the DBExpress driver for MS SQL Server 5.01 and am having problems with numeric(m, n) parameters when m>14 and/or n>4
Problem 1
When n>4 it seems that inputparameter values are rounded to 4 decimals; this can even lead to an exception:
Project x raised exception class EMSError with message 'Error converting data type money to numeric.'
In this case the parameter is Numeric(6,5) and the value is 9.99999
When checking the SQL statement with SQL Profiler I see (something) like this:
declare @P2 varchar(67)
select @P2 = NULL
exec dbo.MyStoredProc $10.0000, @P2 output
select @P2
So the value is rounded to 10.0000 and now longer fits into numeric(6,5). (When I execute the above statement in SQL Server Management Studio, it gives the same error message)
Question 1:
Why is the money datatype/notation used for inputparameter, while the outputparameter is used as varchar (note the @P2 parameter is defined as numeric(6,5) in the stored procedure.
Can the inputparameter be forced to be also varchar and not be rounded to 4 decimals?
Note: when I use the standard DBExpress driver by Embarcadero (D2010), the inputparametervalues are set via varchar, so they are not rounded and have the correct numeric scale.
Problem 2:
When m>14 I get an exception
Project x raised exception class EInvalidOp with message 'Invalid floating point operation'
I guess this has to do with the rounding/manipulation of inputparameter values when the SQL statement is constructed
Question 2:
How can I prevent this exception?