I drop on a TUniQuery and set Options.QueryRecCount:=true and Readonly:=true;
I get the query.recordcount = 88,349
If I then do a While not query.EOF do
begin
query.next;
end;
This loop will occur 1,050 times, the actual recordcount. So internally the dataset is actually 1050 records.
I can also load the query Options.QueryRecCount:=false and then
query.Last;
query.First;
I get the correct query.recordcount = 1050.
This is the query
Code: Select all
SELECT DISTINCT
INVDTBL.*,
INVHTBL.*
FROM
INVDTBL
INNER JOIN INVHTBL ON (INVDTBL.INVD_ORDER_NO = INVHTBL.INVH_ORDER_NO)
INNER JOIN ITEMTBL ON (INVDTBL.INVD_ITEM_NUMBER = ITEMTBL.ITEM_NUMBER)
INNER JOIN LOCATIONITEMS ON (LOCATIONITEMS.ITEMID = ITEMTBL.ITEM_NUMBER)
WHERE
(INVD_ITEM_NUMBER <>'')
AND (INVH_INV_DATE >='2017-03-01' and INVH_INV_DATE <='2017-03-24')
AND ((INVHTBL.INVH_STATUS= 'CrNote') OR (INVHTBL.INVH_STATUS= 'Invoice'))
AND (ITEMTBL.ITEM_ACTIVE_YN='Yes') AND (LOCATIONITEMS.ACTIVE_YN=1)
ORDER BY
INVD_ITEM_NUMBER ASC
It seems that this method is now for some reason unreliable. This is a serious problem as the recordcount can be used to set progressbars, warning messages, etc. If QueryRecCount is not reliable, can you suggest a better/faster way to get this count?