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