MariaDB 10.0.32 on Linux, client: libmysql 5.5.43.0, Lazarus 1.6.2, FPC 3.0.0, Windows XP
There are another applications adding records and others changing data and all work well.
In my application I want to see summarized data. This app does not change any data. I have
Query.SQL.Text := 'SELECT COALESCE(COUNT(ID),0) as count from main where used_where=0 and sold_where IN (3,6);';
Query.Active:=True;
if Query.BOF and Query.EOF
then Memo.Lines.Append('No records.')
else Memo.Lines.Append('Count : '+ Query.FieldByName('count').AsString);
I have a Timer at every 10 seconds runs
Memo.Lines.Clear;
Query.Refresh;
and expected to see actual data, but not. It shows actual data just after application starts and Refresh does not work. I added curtime() to test like this:
Query.SQL.Text := 'SELECT COALESCE(COUNT(ID),0) as count, curtime() as ct from main where used_where=0 and sold_where IN (3,6);';
Query.Active:=True;
if Query.BOF and Query.EOF
then Memo.Lines.Append('No records.')
else Memo.Lines.Append('Count : '+ Query.FieldByName('count').AsString+
' , ' + Query.FieldByName('ct').AsString);
Now at every 10 seconds clock shows actual time but count does not changes.
I changed Query.Refresh to Query.Active:=False and then to True. And more: I need another sums and I change SQL.Text of the same Query to another one 'SELECT COUNT ...' and third, and then again the first SELECT mentioned above and all sums shows actual data after application starts and does not after that.
Why Refresh does not refreshes sums and how to resolve this?
Thank you in advance!
Added: One of queries is
SELECT COALESCE(COUNT(ID),0) as count FROM main
WHERE now() < addtime(used_datetime,''00:40:00'');
and this works as expected (Edit: Not in all cases. ??? Not refreshes when grows and refreshes when decreases ???).