deleting a record from random file 
Author Message
 deleting a record from random file

Do i need to rewrite the file so that the position left is full?

thanks i know I shouldnt bother the group like this:)



Thu, 17 May 2001 03:00:00 GMT  
 deleting a record from random file
Michael,

You can only delete a record from a non-Database(Such as Access or Oracle)
file by:

1.  Copying the file to a new file and not copying the deleted records.
2.  Mark the deleted records with some flag in some field as deleted.  Then,
your app should ignore any records that are marked as deleted.

One advantage to method (2) above is that its quite easy to "Un-delete" a
record should the need arise!

Helmar B. Herman


Quote:
>Do i need to rewrite the file so that the position left is full?

>thanks i know I shouldnt bother the group like this:)



Thu, 17 May 2001 03:00:00 GMT  
 deleting a record from random file
On Sun, 29 Nov 1998 16:32:56 +1000, Michael {*filter*}

Quote:

>Re: deleting a record from random file
>Do i need to rewrite the file so that the position left is full?

If you are using Open, Input, and Print for your file access, then
there is no easy way to "delete" a record in your file.  What most
systems do is have an index file of some sort that simply failes to
index any "deleted" record that is still in the file.  Often a
"deleted record will just have an extra one character field that is
the deleted flag - "Y"" if deleted, and "N" if not.  (Any scheme will
do)

Then you have to write a compress function that removes these deleted
records periodically.  You should note that even as far fetched and
convuluted as this sounds, Access has a Compress option on the menu
that does just this.  Yes, this is how database systems reclaim unused
space :)

Optionally, you can code your system to reclaim deleted records when
new records are added if you use an index and natural order does not
matter to you.

If your random access file is less that 1,000  records on a local hard
disk, then the speed cost of rewriting the file when you delete is
small, and you might consider just doing that.



Thu, 17 May 2001 03:00:00 GMT  
 deleting a record from random file



Quote:
>Do i need to rewrite the file so that the position left is full?

You can compress random files only, if you never access the records in a random
fashion, by their record number! And if you don't need real random access, you
better should use Binary files instead of Random.

Whenevery gaps must be removed from a file, the whole file must be rewritten,
regardless whether it's a text file, a database or any other type of file.

DoDi



Sat, 19 May 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. How to delete Random file record!

2. Can you delete records from a Random file?

3. Delete a record from a Random Access File?

4. Deleting Random File Record

5. Random Access File - Deleting records

6. How to delete record in random-access file?

7. Random access files - having and finding multiple types of record in one file

8. Deleted records when text file is linked as table (#deleted)

9. How to Delete a record(or records) inside an open file

10. Deleting the whole content of a Binary/ Random Access File

11. Deleting From Random File

12. number of records in a random access file?

 

 
Powered by phpBB® Forum Software