[Lazarus] Problem with zeos and sqlite-3
luiz americo pereira camara
luizmed at oi.com.br
Fri Feb 15 00:29:01 CET 2013
I just tested with sqlite3ds and works fine. See test below. You may
look at its source and see if the approach used can be adapted for
zeos
Luiz
Sqlite3Dataset1.FileName := 'data.db';
Sqlite3Dataset1.TableName := 'Test';
if not Sqlite3Dataset1.TableExists then
begin
Sqlite3Dataset1.FieldDefs.Add('AFloat', ftFloat);
Sqlite3Dataset1.CreateTable;
Sqlite3Dataset1.Open;
Sqlite3Dataset1.Append;
Sqlite3Dataset1.FieldByName('AFloat').AsFloat := 1;
Sqlite3Dataset1.Post;
Sqlite3Dataset1.Append;
Sqlite3Dataset1.FieldByName('AFloat').AsFloat := 2;
Sqlite3Dataset1.Post;
Sqlite3Dataset1.ApplyUpdates;
Sqlite3Dataset1.Close;
end;
Sqlite3Dataset1.SQL := 'Select SUM(AFloat) as SUM1 from Test';
Sqlite3Dataset1.Open;
S := Format('Type: %s Value: %f',
[Fieldtypenames[Sqlite3Dataset1.FieldByName('SUM1').DataType],
Sqlite3Dataset1.FieldByName('SUM1').AsFloat]);
// Type: Float Value: 3,00
2013/2/14 zeljko <zeljko at holobit.net>:
> Hi,
> When using eg. sum(somecolumn) AS sum1, sum(somecolumn2) AS sum2 sqlite
> returns (zeos recognizes) result columns as string not as float.
> I've tried CAST(sum(somecolumn) AS REAL) AS sum1 but have same problem.
> If I use pure data from table (eg. item INTEGER,value float) then results are
> ok.
>
> I know that sqlite3_column_type() is tricky about correct results, but asking
> if someone have solution for this.
>
> Anyone ?
>
> zeljko
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
More information about the Lazarus
mailing list