Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
_Tally VS Reccount() - Yikes!
Message
 
 
To
17/07/2003 01:24:17
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00810957
Message ID:
00811016
Views:
16
It's better to use _TALLY always because adding new index to a table may turn your nonfiltered cursor into filtered. Just recently I had to truck down such problem. The program that haven't been changed for a long time started producing wrong result. Te culprit was combination of RECCOUNT() on a cursor and new index added to the table.

NOFILTER always and only ommit it if you want filtered cursor. Otherwise adding new index to a table may turn

>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...
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform