Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Reccount()
Message
 
To
25/08/2016 13:03:50
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:
01640798
Views:
137
Likes (1)
>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.
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform