Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
_Tally VS Reccount() - Yikes!
Message
From
17/07/2003 01:24:17
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
_Tally VS Reccount() - Yikes!
Miscellaneous
Thread ID:
00810957
Message ID:
00810957
Views:
55
Many of you probably already know this, but I know that there are likely some who don't. If you use Reccount() to check the results of a SQL-Select statement on native VFP tables, it may not give you the total of the query results. If you're query is fully optimizable and carried out on a single table without any calculated expressions, VFP will simply apply a filter to the original table. What I didn't expect was to see Reccount() report on the record count of the original table instead of the resulting cursor. I got my butt kicked trying to figure out why my code was not working. _Tally will give you the correct results. Of course you have to be careful with this command as well, it must be placed immediately after the command you want to have _tally report on. Otherwise you may get faulty results.

If speed is not an issue you can use the NOFILTER clause which will force a new recordset to be built, which will then produce a recordset which Reccount() will correctly report against. For example:

SELECT aField
FROM aTable
Where afield = something
INTO aCursor NOFILTER

IF USED('aCursor') and RECCOUNT('aCursor) > 0
... do whatever

If speed is an issue and you want to maintain the VFP optimization then you can use

SELECT aField
FROM aTAble
WHERE aField = something
INTO aCursor

IF _Tally > 0
... do whatever

Remote queries are another thing...
Next
Reply
Map
View

Click here to load this message in the networking platform