Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2024-07

SQlite format issue in DBGrid with non persistant field definition

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

John Landmesser

?Hi,

?why do i have this format issue with aggregat function as SUM quering a SQLite Database with DBGrid and TQuery?

No format issues if i use in terminal:

./sqlite3 -table ./laufdaten.db 'SELECT SUM( km_gelaufen )? FROM laufdaten;' +--------------------+
| SUM( km_gelaufen ) |
+--------------------+
| 978.639??????????? |
+--------------------+

But using DBGrid and ZQuery from ZeosLib i get:

SUM(km_gelaufen );
9,8E2;

That scientific notation is only shown in DBGrid, the correct value 978.639 is copied to clipboard by Ctrl + c

I googled and found a workaround but i would like to know: why is the? DBGrid using this scientific notation ?

The issue is of course gone if i have persistant field definitions where i can set Field.Displayformat

Tipps are welcome

John

Reply by email

Joaozinho
to John Landmesser

Try with TOTAL instead:

TOTAL(km_gelaufen) as km_gelaufen

Or with ROUND:

ROUND(TOTAL(km_gelaufen), 3) as km_gelaufen

John Landmesser wrote 35 lines
?Hi, ?why do i have this format issue with aggregat function as SUM quering a SQLite Database with DBGrid and TQuery? No format issues if i use in terminal: ./sqlite3 -table ./laufdaten.db 'SELECT SUM( km_gelaufen )? FROM laufdaten;' +--------------------+ | SUM( km_gelaufen ) | +--------------------+ | 978.639??????????? | +--------------------+ But using DBGrid and ZQuery from ZeosLib i get: SUM(km_gelaufen ); 9,8E2; That scientific notation is only shown in DBGrid, the correct value 978.639 is copied to clipboard by Ctrl + c I googled and found a workaround but i would like to know: why is the DBGrid using this scientific notation ? The issue is of course gone if i have persistant field definitions where i can set Field.Displayformat Tipps are welcome John

Reply by email

John Landmesser
to Werner Pamler
Werner Pamler wrote 9 lines
Am 19.07.2024 um 14:40 schrieb John Landmesser via lazarus: > The issue is of course gone if i have persistant field definitions where > i can set Field.Displayformat But nothing prevents you to do this also with auto-created fields: ??? TFloatField(SQLQuery1.FieldByName('Number')).DisplayFormat := '#,##0.000';

Yes i did that allready as a workaround ( thanks to google ):

procedure TForm1.DBGrid2DblClick(Sender : TObject);
var index : integer;
begin
 ? index := DBGrid2.SelectedField.Index;
 ? TNumericField(ZQuery2.fields[index]).DisplayFormat := '#,###.000';
end;

But i think its an issue of Zeoslib, that should be fixed.

Reply by email