• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

NX: URLy Bird - Deleted Records

 
Ranch Hand
Posts: 493
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Jim,
You asked in the criteriaFind() thread:


Hi Bharat,
This URLy bird project looks cryptic to me. U state that u do not allow the client to view any deleted records. My concern is
1. Can u explain what happens to the deleted record. Do we compress the file or mark it deleted and reuse. And if we do delete, how does this record ever get re-used since the requirement states that the update method throws RecordNotFoundException, meaning if trying to update deleted record , throw an e!
There is talk of adding new records to this database. Does this mean:
2. we can willy nilly add new records to the database, and if we can under what conditions do we do so, do we add a record as long as we have keep the hotel name and location or are there other factors.
I am really puzzled about this.
Thanks.


If you are an "old" dbase/Clipper/FoxPro person like me, you would recall that these tools used to have ".dbf" files which allowed to you to go to a particular record and delete them. When deleting, you didn't really (I mean physically) delete the record but only marked it for deletion. If you issued a "pack" command however, the system will physically remove the record and compress the "dbf" file.
If none of the above makes sense to you, don't worry about it. Most likely you are not "old", you are lucky!
Seriously, for the URLy Bird assignment; You do not do "pack", i.e., you only mark the record for deletion. My instructions state:


1 byte "deleted" flag. 0 implies valid record, 1 implies deleted record.


What you do is for a given record you first locate this byte, and to delete it, you just set it to "1". As simple as that. So the next time your program is reading the records, it checks this byte. If it is turned "on", i.e., set to 1, you want to skip the record since you don't want the user to see a deleted record.
When you want to add a record, however, you start at the first record and read sequentially down until you locate a deleted record. If you find one, you can reuse it for storing the record that you want added to this file. Simply replace, i.e., write over, the data in the deleted record with data for your new record. Also set the deleted flag to "not deleted," i.e., equal to 0. Remember, you are reading FixedLengthStrings, therefore, you should be writing FixedLengthStrings as well. That is the only way you can guarantee the integrity of the given datafile.
I hope this is of help to you.
Regards.
Bharat
 
Ranch Hand
Posts: 555
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bharad,
Sorry for interrupting your discussion with Jim, but

What you do is for a given record you first locate this byte, and to delete it, you just set it to "1". As simple as that.


is not just a good idea, it is the how it must be done according to URLyBird assignement.
Best,
Vlad
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

If you are an "old" dbase/Clipper/FoxPro person like me


Me too. Actually we finally rewrote all our Foxpro 2.6 application into VB and Oracle Forms. no more .dbf's and no more corrupted tables and indexes. I am a very happy camper about that.
Mark
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Jim,
You asked in the criteriaFind() thread:

Jim who? Personally I don't recognize this conversation. Got a link?
 
Bharat Ruparel
Ranch Hand
Posts: 493
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Jim,
Jim Brown posted a question addressed to me in the following thread:
Topic: criteriaFind() doubt
He is rather new to the ranch and asked me a question that was unrelated to the question that I was trying to ask in the aforementioned thread. I thought it was better to start a new thread and answer his question in the new (this) thread. Now that I have your attention, would you please answer my question in that thread?
Thanks.
Bharat
 
Bharat Ruparel
Ranch Hand
Posts: 493
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Mark,
Good to hear from a fellow FoxPro person. Tell you the truth, I am not sure if I buy all this new object-oriented stuff. Seems woefully unproductive to me. We could get things done a whole lot faster.
Regards.
Bharat
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now that I have your attention, would you please answer my question in that thread?
Sorry, I don't know enough about these particular URLyBird requirements. I'll let others handle this one.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bharat,
in summary,
1. UpdatedRecord method call updates a currently valid record.
2. CreateRecord method call "updates" the deleted record with the new values.
Thanks, i really appreciate this,
 
Bharat Ruparel
Ranch Hand
Posts: 493
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Quite correct and you are welcome.
Welcome to JavaRanch.
Regards.
Bharat
 
If I'd had more time, I would have written a shorter letter. -T.S. Eliot such a short, tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic