Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reccount()
Message
From
25/10/2016 17:20:00
Mike Yearwood
Toronto, Ontario, Canada
 
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:
01642363
Views:
168
>>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")
>
>
>
>Maybe the stupid stuff happens because you are using bad code on purpose to prove your point? There is no need to provide an alias other than to make it fail, in order for you to affirm that there is only ONE way you should show me an scenario where the following command will fail:
>
>SELECT * FROM c_temp WHERE !DELETED() INTO CURSOR somecursor1
>
>Of course, keeping all in the context of the question asked.

I find your tone rude and offensive, but no one bothers to question that, and frankly I don't bother worrying about it anymore. Why should I OR ANYONE attempt to be polite? For that matter who really gives a crap about politeness - which is all in the eye of the beholder. I can only say I am not deliberately trying to offend, but you may or may not have been. So what? Even Tore mistakes my statements for an attack. Even Queen Elizabeth recently called the Chinese rude. Should war be started over this ridiculous, childish weakness?

I am only interested in best practices. That is all I try to show. Too many are too wishy-washy in their practices and get all defensive instead of having an open mind enough to cut away the chaff. Any function that can take an alias is suspect in VFP SQL. That it works only in tiny fractions of the use cases does not make it worth keeping. The fact that it fails in most cases, is reason to abandon the practice.

While SET DELETED is ON, the command you list does not fail. But DRY principal applies. Adding WHERE !DELETED() is is redundant redundant. I have deleted records in my table. SELECT * FROM c_Temp where deleted() . The answer is zero. That is a also a failure. It's a bad practice no matter how it is sliced.
Previous
Reply
Map
View

Click here to load this message in the networking platform