Types BCD and FMTBCD in the RAD Studio 10.3 Rio by Fernando Rizzato

emailx45

Местный
Регистрация
5 Май 2008
Сообщения
3,571
Реакции
2,438
Credits
573
Types BCD and FMTBCD in the RAD Studio 10.3 Rio
[SHOWTOGROUPS=4,20]
January 12, 2019 - by Fernando Rizzato (MVP Lead South-America)

bin10.gif

Theoretical Aspects
Version 10.3 of Delphi and C ++ brought a number of optimizations in RTL and also in the area of data access. Many drivers have been updated and / or optimized, as we can see in the Для просмотра ссылки Войди или Зарегистрируйся this version.

Among them, there was an adjustment in the mapping of BCD and FMTBCD type fields. We can say that as of 10.3, the definition between BCD and FMTBCD strictly follows the standards defined for these two types of data, which did not occur in previous versions according to the database used.

In summary, BCD ( binary-coded decimal ) provides greater precision and accuracy than floating point numbers. Its use will be determined according to the type of data and the precision defined in the database.

The difference between BCD (technically Для просмотра ссылки Войди или Зарегистрируйся ) and FMTBCD (technically Для просмотра ссылки Войди или Зарегистрируйся ) is directly related to the number of decimal places and significant digits employed.
A BCD will support numbers with up to 20 significant digits and 4 decimal places. In addition, an FMTBCD will be employed. In practice, internally, the BCD will be treated as a “ Currency ” for performance reasons, and an FMTBCD will effectively be a binary-coded decimal in the strict aspect of its definition.

Possible impacts on your project
If, in a version migration to 10.3 Rio, your application “complains” that the fields previously mapped as BCD should now be FMTBCD, this is due to the aforementioned optimizations.
To keep everything as it was, that is, to make Delphi and C ++ continue to map the fields as BCD, and not try to take them to FMTBCD, you can adjust the following settings in FireDAC:
  1. set the FDQuery.FormatOptions.MaxBcdPrecision property to a value higher than the default, like 20 for example.
  2. set the FDQuery.FieldOptions.UpdatePersistent property to True
In theory, everything that was working correctly will remain, without prejudice to your project. For new projects or additions of new data sets, it is recommended to adopt the default mapping generated by the tool.

screen shot 2019-01-12 at 20.51.44



Gladiston Santana says:
January 29, 2019 at 8:58 am
  • Well, in practice, I felt incompatibility with certain types, in addition to * bcd, also the currency in TFields and Firebird. I had to adapt my code to not use query1.ParambyName ('xxx') anymore. AsInteger because if the type I send is byte or anything that is mistaken for smallint, Firedac sends an exception to me.
    Now I changed everything to .Value to the detriment that I had learned that in Delphi whenever possible it is good to be deterministic instead of using Variant (.Value or .AsValue).
    Great that your article clarified some things, I was already thinking that it was Delphi with tantrum only with me.

[/SHOWTOGROUPS]
 
Последнее редактирование: