|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Delete record in Random access fileHi
I have a small aplication that stores data in a random access file. I'm able to modify records, and add new records. But how can I delete a certain record and remove it enirely from the file? /A. "Andy.I" <Andy.l@community.nospam> wrote in message A quick and easy solution would be to "flag" it as deleted, but leave it in news:28A16BB3-C348-47E9-B4D6-0DE441A72222@microsoft.com... > Hi > > I have a small aplication that stores data in a random access file. I'm > able to modify records, and add new records. But how can I delete a > certain record and remove it enirely from the file? > > /A. the file. You then have another procedure that removes all deleted items in one go every now and then or simply overwrites a "deleted" slot when you add new records (i.e. the file always grows). There is no way to selectively "remove" some chunk of data in the middle of a file. You have to copy up to the point of deletion and append data after the point of deletion into a new file. Think about a database like SQL Server, it has a "shrink" method and it will re-use unallocated space, but the file only ever gets bigger unless you actually tell it to shrink. Deleting records simply returns them to the pool of usuable space. I'm not sure about the context of all of this, or whether you can modify your scheme significantly so it's difficult to state with any more certainty a better approach. Do you know if there are any good resources for this on the web or any
examples? Show quoteHide quote "Robinson" <toomuchspamhaspassed@myinboxtoomuchtoooften.com> wrote in message news:ekeok9$r15$1$8302bc10@news.demon.co.uk... > > "Andy.I" <Andy.l@community.nospam> wrote in message > news:28A16BB3-C348-47E9-B4D6-0DE441A72222@microsoft.com... >> Hi >> >> I have a small aplication that stores data in a random access file. I'm >> able to modify records, and add new records. But how can I delete a >> certain record and remove it enirely from the file? >> >> /A. > > A quick and easy solution would be to "flag" it as deleted, but leave it > in the file. You then have another procedure that removes all deleted > items in one go every now and then or simply overwrites a "deleted" slot > when you add new records (i.e. the file always grows). There is no way to > selectively "remove" some chunk of data in the middle of a file. You have > to copy up to the point of deletion and append data after the point of > deletion into a new file. Think about a database like SQL Server, it has > a "shrink" method and it will re-use unallocated space, but the file only > ever gets bigger unless you actually tell it to shrink. Deleting records > simply returns them to the pool of usuable space. > > I'm not sure about the context of all of this, or whether you can modify > your scheme significantly so it's difficult to state with any more > certainty a better approach. > > |
|||||||||||||||||||||||