>>My problem is:
>>
>>I loop through a table multiple times and mark records for deletion that meet certain conditions. How come, even though I have SET DELETED ON, the deleted records keep appearing in the continuous loop/scan.
>>
>>I have the following code:
>>
>>DO WHILE .T.
>> SELECT mytable
>> SCAN ...
>> IF ...
>> DELETE && Mark record for deletion
>> ENDIF
>> LOOP
>> ENDSCAN
>>ENDDO
>>
>>In the Init of the form I specify SET DELETED ON. When I browse the mytable it shows no records unless I specify SET DELETED OFF and rebrowse mytable.
>>
>>Any ideas? I must be forgetting something. Thanks for helping.
>
>Deleting records does not remove them from the database and SET DELETED ON/OFF only affect a browse view. If you do any kind of unconditional loop through the database, it will still include the deleted records. As I see it, the options are: a) include a FOR NOT DELETED condition on the scan
> b) pack the database after the deletes (not recommended)
> c) instead of deleting the records, BLANK them
>HTH
SET DELETED ON/OFF affects much more than BROWSEs. It affects any command which can have a FOR clause. SCAN, for instance. If DELETED is ON, a SCAN is an implied SCAN FOR NOT DELETED(). Also, SEEK() will not find deleted records if DELETED is ON. Also COPY TO ... implies COPY TO ... FOR NOT DELETED() if DELETED is ON. The list goes on and on.
Rich.
Rich Addison, Micro Vane, Inc., Kalamazoo, MI
Relax, don't worry, have a homebrew.
- Charlie Papazian, The New Complete Joy of Home Brewing