We have problem with Decimal columns. Using SQL Server with FireDAC.
Because we need preserve full precision we use BDC type fileds. Colums in DB are defined decimal(28,10).
If value is set to field like this:
[table].FieldByName(‘Cost’).AsDecimal := 1.111111111111111111111111111111111111111111111;
then everything is working correctly and it is saved to DB formatted as expected.
Here is catch - we are scaling value. If value saved in BCD is multiplied by fraction then result can exceed precision and fail with FireDAC error.
cost := [table].FieldByName(‘Cost’).AsDecimal;
scale := 0.9999999999999999999999999999999999;
[table].FieldByName(‘Cost’).AsDecimal := cost * scale;
I tested this with TFDQuery and TFDConnection and it also fails. Fortunately both these components have option FormatOptions.CheckPrecision and FormatOptions.Round2Scale. Should not be BCD values to be formatted automatically to destination field format? Or is there any way how to set behaviour via exposed properties?