ZMemTable does not support the ftCurrency type

The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
Post Reply
abonic
Junior Boarder
Junior Boarder
Posts: 26
Joined: 25.11.2016, 17:00

ZMemTable does not support the ftCurrency type

Post by abonic »

Steps to reproduce problem:

Code: Select all

   
ZMemTable1.Active := False;
ZMemTable1.FieldDefs.Clear;
ZMemTable1.FieldDefs.Add('price', ftCurrency);
ZMemTable1.Open; // <- Error: ZMemTable1: Type mismatch for field 'price', expecting: Blob actual: Currency.
I think the error is in:

Code: Select all

TZAbstractRODataset.GetFieldClass(FieldType: TFieldType): TFieldClass;
There is no translation defined for the ftCurrency type in that function, so it ends up as TZBLobField.
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 765
Joined: 18.11.2018, 17:37
Location: Hungary

Re: ZMemTable does not support the ftCurrency type

Post by aehimself »

The issue is not that simple. Either we simply add a TCurrencyField (which is probably undesirable considering all the TZxxField variants) in the method you mentioned but the good solution is to implement the currently missing TZCurrencyField.

I don't have access to any RDBMSes at the moment but it would be interesting to check how TZ(ReadOnly)Query behaves, what kind of field it creates when the query returns an actual currency field. I will be able to test this on Sunday, when I will be back from abroad.
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1918
Joined: 17.01.2011, 14:17

Re: ZMemTable does not support the ftCurrency type

Post by marsupilami »

I added a TZCurrencyField. TZMemTable should now be able to create a corresponding field. Please test the current version of the 8.0-patches branch.

Note: T(Z)CurrencyField is derived from TFloatField - so doesn't do exact numerics. We discourage the usage of this field type. Please use one of the BCD field types and set the Currency property to true.
abonic
Junior Boarder
Junior Boarder
Posts: 26
Joined: 25.11.2016, 17:00

Re: ZMemTable does not support the ftCurrency type

Post by abonic »

It works as it should, it seems. Thank you.

I have already opted for ftBcd in my application. The attempt with ftCurrency was just a quick prototype.

I absolutely agree that this field type (with a very misleading name) should be avoided, but I think it's good for ZEOS to support it now, even if it's only for compatibility and completeness.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1918
Joined: 17.01.2011, 14:17

Re: ZMemTable does not support the ftCurrency type

Post by marsupilami »

aehimself wrote: 02.05.2024, 17:10 I don't have access to any RDBMSes at the moment but it would be interesting to check how TZ(ReadOnly)Query behaves, what kind of field it creates when the query returns an actual currency field. I will be able to test this on Sunday, when I will be back from abroad.
According to EgonHugeist Zeos never creates fields of the kind fkCurrency - which probably is why we didn't have a TZCurrencyField. Instead one of the BCD field types should be created. Maybe we set the currency property to true too.
Post Reply