deleting records from a table  
Author Message
cookieCutter





PostPosted: Visual FoxPro General, deleting records from a table Top

Hi all,

I have a table(all_wID) that consists of 160,000 IDs ( IDs are numbered from 1 to 160,000). Every time i use an ID in a particular application, I want that ID deleted from the table(all_wID)

i use -> delete from all_wID where work_id = find.work_id

this is saying if i use one of the IDs, delete it from the list, then when i use the application again i need to check to see if the id has been used already. I query all_wID to see if it has been deleted, and if it hasn't been, i use the ID and then delete it.

My problem is getting the record to delete. The table consisting of the IDs, doesn't delete the record, but instead makes the 1cm border to the left of the column black. Does any1 now how to acutally delete a record from a file, or if i'm doing the right thing, how do i check if the record has been marked for deletion

Thanks In Advance,
Mike



Visual FoxPro2  
 
 
dni





PostPosted: Visual FoxPro General, deleting records from a table Top

You can check for deletion(marked for delettion) with DELETED().

To ignore records marked for delete in a scope you can use SET DELETED ON.

To delete them for ever you can use PACK.



 
 
Alex Feldstein





PostPosted: Visual FoxPro General, deleting records from a table Top

The black marker you see is the Delete Flag. Remember than in VFP (XBase) DELETE does not actually delete a record but it marks it for deletion.

Records are not actually deleted until you  PACK the table (which needs EXCLUSIVE use and is therefore infrequently done).

If you want to see deleted records you coud have an index on DELETED() and SEEK DELETED() or without the index: LOCATE FOR DELETED().

In the Command Box you can also BROWSE FOR DELETED()

 

You do not need to PACK as you can always reuse deleted records (see help for BLANK and RECALL. commands)

 

Also look in help for

SET DELETED ON|OFF

 


 
 
Markish





PostPosted: Visual FoxPro General, deleting records from a table Top

Hi,

To add on Alex point, records exist as long as 'pack' is issued. The best practie in your situation is using a flag field for checking the usage of the the id in the table so that you avoid running into situation of issuing pack accidentally.

Regards,

Markish