Type mismatch expecting: Currency actual: extended

The forum for ZeosLib 7.2 Report problems. Ask for help, post proposals for the new version and Zeoslib 7.2 features here. This is a forum that will be edited once the 7.2.x version goes into RC/stable!!

My personal intention for 7.2 is to speed up the internals as optimal a possible for all IDE's. Hope you can help?! Have fun with testing 7.2
Post Reply
louis
Expert Boarder
Expert Boarder
Posts: 107
Joined: 02.01.2009, 19:41

Type mismatch expecting: Currency actual: extended

Post by louis »

Hello,
in Zeos 7.2.4 I get a:
"Type mismatch for field xxx, expecting: Currency actual: Extended."

In Firebird 2.5 Table1, "PREZZO" is a field of type Numeric(18, 4).

In this query:

Code: Select all

SELECT
  *
FROM
  TABLE1
In Fields Editor a TCurrencyField is added for field PREZZO.

In this query:

Code: Select all

SELECT
 PREZZO
FROM
  TABLE1
In Fields Editor a TExtendedField is added for field PREZZO.

Why?

I discovered this behaviour because I updated from 7.2.? (how I verify build?) to 7.2.4 and my application raises a lot of Type mismatch exceptions.

What I can verify?

Thanks.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1918
Joined: 17.01.2011, 14:17

Re: Type mismatch expecting: Currency actual: extended

Post by marsupilami »

Hello Louis,

it seems that you have persistent fields in your application. Right-click on the TZQuery where this happens. A menu appears where you can choose to open the Field Editor. In the field editor remove the fields and add them again.

Using TCurrencyField for numeric values was a problem in early Zeos 7.2 development. We changed these places to use TFloatField or TExtendedField later on.

Note: I suggest to avoid persistent fields as much as you can because this will lead to problems like this. Even more so if you decide to use more than one type of database in your application. In my applications I use the AfterOpen event of TZQuery to set fields properties like this:

Code: Select all

  Query.FieldByName('Field_1').Visible := False;
  (Query.FieldByName('Field_2') as TExtendedField).Currency := True;
louis
Expert Boarder
Expert Boarder
Posts: 107
Joined: 02.01.2009, 19:41

Re: Type mismatch expecting: Currency actual: extended

Post by louis »

Using TCurrencyField for numeric values was a problem in early Zeos 7.2 development. We changed these places to use TFloatField or TExtendedField later on.

But, in Zeos 7.2.4 stable, why if I have this query:

Code: Select all

SELECT
  *
FROM
  TABLE1
I gain a TFloatField (I had mistake writing TCurrencyField, TCurrencyField is on zeos 7.2.0b).

while if the query is:

Code: Select all

SELECT
  PREZZO
FROM
  TABLE1
I gain TExtendedField?

In both cases I should get TExtendedField. Why not?

I see that my post seems to be a duplicate of [url] http://zeoslib.sourceforge.net/viewtopi ... 40&t=92540 [/ url] but it's different because I want to understand why I get TFloatField or TExtendetField for the same FIELD on the same TABLE as the query is written.

Thanks.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1918
Joined: 17.01.2011, 14:17

Re: Type mismatch expecting: Currency actual: extended

Post by marsupilami »

Hello Louis,

this shouldn't happen. Could you please provide the complete DDL (create table ...) for your table?

Best regards,

Jan
louis
Expert Boarder
Expert Boarder
Posts: 107
Joined: 02.01.2009, 19:41

Re: Type mismatch expecting: Currency actual: extended

Post by louis »

marsupilami wrote:this shouldn't happen. Could you please provide the complete DDL (create table ...) for your table?
Yes, FB 2.5:

Code: Select all

CREATE DOMAIN CURRENCY_D
 AS Numeric(18,4)
 DEFAULT 0.00
 NOT NULL
;

CREATE TABLE TABLE1
(
  ID Integer NOT NULL,
  PREZZO CURRENCY_D DEFAULT 0.00,
  CONSTRAINT ID_PK PRIMARY KEY (ID)
Thanks.
Regards.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1918
Joined: 17.01.2011, 14:17

Re: Type mismatch expecting: Currency actual: extended

Post by marsupilami »

I was able to verify this problem and created a ticket on the bugtracker (#351) as well as a test to demonstrate the problem in our test suites.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1918
Joined: 17.01.2011, 14:17

Re: Type mismatch expecting: Currency actual: extended

Post by marsupilami »

Hello louis,

it seems that EgonHugeist checked in a solution. Could you please check if the problem is solved in the current 7.2-testing branch on SVN?
Best regards,

Jan
louis
Expert Boarder
Expert Boarder
Posts: 107
Joined: 02.01.2009, 19:41

Re: Type mismatch expecting: Currency actual: extended

Post by louis »

marsupilami wrote:it seems that EgonHugeist checked in a solution. Could you please check if the problem is solved in the current 7.2-testing branch on SVN?
Ok, now in both cases I get a field of type TExtendedField.

But, why, in Zeos, is not safe to use TCurrencyFields?

Thanks.

Regards.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1918
Joined: 17.01.2011, 14:17

Re: Type mismatch expecting: Currency actual: extended

Post by marsupilami »

Hello Louis,

it is safe to use currency fields in Zeos. But Firebird doesn't have a currency or money data type so there is nothing there that we can map to be a TCurrencyField by default.

Best regards,

Jan
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: Type mismatch expecting: Currency actual: extended

Post by EgonHugeist »

louis wrote:
marsupilami wrote:it seems that EgonHugeist checked in a solution. Could you please check if the problem is solved in the current 7.2-testing branch on SVN?
Ok, now in both cases I get a field of type TExtendedField.

But, why, in Zeos, is not safe to use TCurrencyFields?

Thanks.

Regards.
The TCurrencyField is a bit messleading. That field-descendant uses double precision floats to represent the numbers.
The TBCDField is what you are looking for. On 7.2 we've a beahvior lock but it's supported already on 7.3.
Fields with higher scale/precision than a currency can have will be mapped to FmtBCD next weeks on 7.3 too. The most conversion methods for all drivers (except ASA -> no idea how) i've ready inbetween.
The TExtended field will no longer be used on 7.3 if the switch is done.
Stay tuned..
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
Post Reply