Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reccount()
Message
From
13/09/2016 19:38:58
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
25/08/2016 15:01:21
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01639965
Message ID:
01640783
Views:
111
>>>>>>Reccount() gives a total of all records in a table whether deleted, or not. What is the most efficient way to determine the number of 'not' deleted records?
>>>>>>
>>>>>>Many thanks!
>>>>>
>>>>>You have to count them.
>>>>>Select count(*) from yourtable where !deleted() into array laDummy
>>>>>?laDummy
>>>>>Note that you must have Set Deleted On for this to work.
>>>>
>>>>There is no need to use deleted() in the query. Functions that take an alias are dangerous in SQL because they do not reference the cursors in the query. Only set deleted on.
>>>
>>>Mike,
>>>
>>>what would than be according to your knowledge a better SQL select statement than the one provided here by Tore?
>>
>>There is only ONE way to safely guarantee you prevent deleted records in SQL.
>>
>>SET DELETED ON
>>SELECT COUNT(*) FROM YOURTABLE INTO ARRAY laDummy
>>
>>Here's the stupid stuff that happens if you use an alias in DELETED() which is why it should be avoided in SQL. You and Tore really need to do things right.
>>
>>CLEAR all
>>clear
>>CREATE CURSOR c_temp (cfield1 c(10))
>>INSERT INTO c_temp (cfield1) VALUES ("1")
>>INSERT INTO c_temp (cfield1) VALUES ("2")
>>INSERT INTO c_temp (cfield1) VALUES ("3")
>>DELETE RECORD 2
>>SET DELETED ON
>>GO TOP IN C_TEMP
>>SELECT * FROM c_temp WHERE !DELETED("c_temp") INTO CURSOR somecursor1
>>?"somecursor1",RECCOUNT("somecursor1")
>>
>>SELECT * FROM c_temp INTO CURSOR somecursor1a
>>?"somecursor1A",RECCOUNT("somecursor1A")
>>
>>SELECT c_temp
>>SET DELETED OFF
>>GO 2
>>SELECT * FROM c_temp WHERE !DELETED("c_temp") INTO CURSOR somecursor2
>>?"somecursor2",RECCOUNT("somecursor2")
>>SELECT * FROM c_temp INTO CURSOR somecursor2A
>>?"somecursor2A",RECCOUNT("somecursor2A")
>>
>
>For your interest, I NEVER delete records. Instead I add a logical field with the meaningful name of reusable. (I also don't use DBFs for data storage anymore, but that's irrelevant in this discussion).
>
>Now, will you please stop this vendetta against me? I don't want to be criticized when all I want is to be helpful. I mean it when I say that I am really offended by your frequent attacks.
>
>Some of these attacks probably wouldn't have happened if English was my primary language, but that's not something you ever consider as far as I have noticed. I confess that I often have big problems explaining exactly what I mean. Is it too much to ask for some room for misunderstandings?

There is no vendetta. If you or anyone post something inaccurate or incorrect, it is not only my right to speak up, but a moral duty. The logical field is no better than the binary deleted index tag. It is a 2 stage index and that means it is a non-discriminating index.

Here's a better option - use a datetime. Then you can recall oldest records first. However, since you're not using dbfs anymore - then why contribute to this kind of discussion? Your knowledge on the matter is becoming outdated and certainly is not backed by any attempt to prove it scientifically.

As for my "tone" - if you will - why should I bother seeming "nice" when others are not called out when they are not only wrong, but also rude?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform