TZParam Currency Values Saved as its Int64 representation

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
TrevorS
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 19.05.2023, 07:38

TZParam Currency Values Saved as its Int64 representation

Post 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]));
Post Reply