Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing records marked for deletion

Status
Not open for further replies.

bigspank

Programmer
Aug 10, 2001
28
0
0
US
I need to know how remove fields marked for deletion using shared. The pack command works fine on tables opened exclusively but I need to be able to delete rows from a record when the table is shared? What do I do? When you sow a thought, you reap an act. When you sow an act, you reap a habit. When you sow a habit, you reap a character. When you sow a character, you reap a destiny.
 
Hello,

There is nothing you can do. You can open table exclusive.

Hope this helps Grigore Dolghin
Class Software
Bucharest, Romania
 
I have 2 suggestions. It's not real elegant, but may be a start.

1. Find a record marked Deleted and then wipe out the fields:
SCAN FOR DELE()
FOR lnCounter = 1 to FCOUN()
lcFoxCommand = "REPL " + FIEL(lnCounter) + " WITH ''" && This part only works with Character fields
ENDFOR
RECA
ENDSCAN

2. Attempt to get the table exclusively on the chance there's only one user (e.g., early morning or late evening) and then pack the table:
ON ERROR llErrorOccurred = .T.
USE (lcTableName) EXCL
ON ERROR

IF !llErrorOccurred
PACK
USE
ENDIF

USE (lcTableName) SHAR

Hope this helps! ;)
 
Hi
Just to make it look like that..
Use the following code to avoid seeing the deleted records on or off..
SET DELETED ON
SET DELETED OFF

Only when you are working as a single user, do the packing. You cant have a work around for this.
ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
LOCATED FOR DELETED()
if found()
SCATTER MEMVAR BLANK
GATHER MEMVAR
RECALL
else
append blank
endif

or if you have a index on deleted()

set order to deleted
goto bottom
if deleted()
SCATTER MEMVAR BLANK
GATHER MEMVAR
RECALL
else
append blank
endif
David W. Grewe
Dave@internationalbid.com
 
As you've probably gathered by now, there is no way to get rid of the records (marked for deletion) unless you have total control of the table. The comments above have offered work arounds but haven't really touched on why you can't permanently delete records in shared mode. The reasons are really logical when you think about it. If the table is opened in shared mode it is assumed that multiple users will want access to the data that is stored in the records -- some of the users may not want you to permanently delete the information located in the records that maybe you decided to delete but that they didn't agree to. That is why Fox requires that all users release their rights to data and give you exclusive rights to the data.

Conversely, Fox assumes that if you have the right to open the data for exclusive use, then you have the right to destroy the data by using the PACK command or even to ZAP it.

Another work around you might consider is to manually do what the pack command does and that is to create a table with exactly the same structure and copy all of the records that are not marked to be deleted into the new table and then delete the original table and then rename the new table with the same name as the original. Of course if the table is a free table that is more simple than if it is part of a database. But of course to do any of this the file could not be open by any other user and you would have to have the access rights to the file to delete it etc. and then you are right back to where you started -- if you have those rights then you probably have the rights to open the table exclusively and use the pack command and Fox manages all the overhead -- like reindexing and so on.

I've probably been long winded -- take a look at Ramani's suggestion and SET DELETED ON and then you won't see the records. Or do like some of the other's have suggested and delete the information from the fields and then reuse the record with new information that you want to keep.

I hope this helps you understand and appreciate why Fox is protecting the data that you might want to protect that others might want to destroy.
 
OK I understand this and now I can move on...and when I did I relaized something awful! While the records marked for deletion, prior to my being able to pack them, they are still showing up in my report. They are not visible on the form, but when I run the report there they are! They even print....that stinks....please help? When you sow a thought, you reap an act. When you sow an act, you reap a habit. When you sow a habit, you reap a character. When you sow a character, you reap a destiny.
 
I believe you use !DELETED() and supress the printing of those records. If you're using an SQL select you can put the !DELETED() in the WHERE clause, I think.

Dave Dardinger
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top