
-----------------------------------
basharious
Mon Mar 27, 2006 11:30 pm

Inventory Database Help
-----------------------------------
Hey Guyzz
I'm working on inventory Database. I'm on Delete a record right now and I just can't get this to work..
So..Here's what I want to do
1.Change the Record's name into deleted
2.move every record to a new file besides the one(s) called deleted
3.remove the old file
4.rename the new file by the name of the old file
Wha't going on is it changes the name to deleted but it does move it to the new file...

Another thing...I think Edit is kinda buggy
Ah...you need the Last_id file (which I provided) but the program will create the database file as soon as you create a record.

-----------------------------------
basharious
Mon Mar 27, 2006 11:32 pm


-----------------------------------
whoops....I forgot to provide the last_id file

-----------------------------------
Tony
Tue Mar 28, 2006 4:22 am


-----------------------------------
what if your program/os/computer crashes during this "deletion" process? You're moving your entire database and deleting the original file.. if something was to happen at that moment, your all data is gone. Just gone.

I think a much simpler way would be to simply overwrite the record to be deleted with the last record in the file. Now the record in question is gone and you have two copies of another record - arbitrary location and the very end. It is trivial to remove the very last record, just move the EOF a step back. No need to move all of the data to another file then back.

-----------------------------------
basharious
Tue Mar 28, 2006 8:42 am


-----------------------------------
yeah...u're right...I never thought this could happen (eventhough it's very probable), but then how would I move the EOF a step back, doesn't it read until it hits the end of file, and I can't change that, Moreover, that would be wasting memory and space (if working with large database) because no one wouold be able to ACTUALLY delete the record.

-----------------------------------
Tony
Tue Mar 28, 2006 2:55 pm


-----------------------------------
aren't you using binary read/write with records? if so, you could seek to a location and write at that point in a file.
