Page 1 of 1

TZParam Currency Values Saved as its Int64 representation

Posted: 28.05.2024, 01:56
by TrevorS
I am upgrading a VCL Win32 application from Delphi 11.3 using Zeos 7.2 to Delphi 12.1 using Zeos 8.0 with SQLlite.

When Inserting/Updating Values into a table using the TZParam AsCurrency property, the value is stored in the table as the int64 representation of the value rather than the real value.

e.g. Query.ParamByName('Amount').AsCurrency := 1.23; will save the amount as 12300

Using AsFloat rather that AsCurrency works fine.
The AsCurrency approach worked fine in Zeos 7.

Code: Select all

      Writeln( 'Creating Database with Amount field as type Float...');
      Connection := TZConnection.Create(nil);
      Connection.Database := '';
      Connection.Protocol := 'sqlite';
      Connection.Connect;
      Connection.ExecuteDirect('CREATE TABLE TableA ( Amount REAL)');

      Writeln( 'Add Amount value of 1.23 using "AsCurrency"... it is saved as 12300 in the database');
      Query := TZQuery.Create( nil);
      Query.Connection := Connection;
      Query.SQL.Text := 'INSERT INTO TableA (Amount) VALUES (:Amount)';
      Query.Prepare;
      Query.ParamByName('Amount').AsCurrency := 1.23;
      Query.ExecSQL;

      Writeln( 'Values is retrieved as 12300 when it should be 1.23');
      Query.SQL.Text := 'SELECT AMOUNT FROM TableA';
      Query.Open;
      Query.First;
      WriteLn( Format( 'Amount AsFloat is %n',[ Query.FieldByName('Amount').AsFloat]));
      WriteLn( Format( 'Amount AsCurrency is %n',[ Query.FieldByName('Amount').AsCurrency]));
      WriteLn( Format( 'Amount AsString is %s',[ Query.FieldByName('Amount').AsString]));

Re: TZParam Currency Values Saved as its Int64 representation

Posted: 05.11.2024, 12:10
by Son
Already have a solution?

Re: TZParam Currency Values Saved as its Int64 representation

Posted: 09.11.2024, 12:45
by marsupilami
Hello Son,

I think we solved the problem. Please thest the latest 8.0-patches branch.

Best regards,

Jan