Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data.delete(), ...

 
Jochen van Waasen
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I have a problem with the following:
Calling delete(record) seems to delete a record but does not update the record count. The db.db provided with my assingment contains 24 records. When I delete a record the record counter keeps the same (24) but only 23 records are available.
Iterating over the 24 records throws a NullPointerException reading record(1) which I have deleted. In this case record number 1 does not exist any longer. What happens if I delete the first 12 records and append 12 records. Record number 1-12 does not exist but 13-36. The record count is 24 but I can't loop 1 to 24.
Do we have to deal with this? This problem occurs to my client refreshing the table after deleting a record.
Kind regards
Jochen
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look into the usage of LIVE_RECORD and DELETED_RECORD in your Data class.
Eugene.
 
Jochen van Waasen
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Eugene Kononov:
Look into the usage of LIVE_RECORD and DELETED_RECORD in your Data class.
Eugene.


Can you give me a little bit more help?
Do you suggest to write my own readRecord() method within criteriaFind()?
Jochen
 
Charles Dupin
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check byte one of any record.
C.
 
BJ Grau
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jochen -
I can't be 100% sure without looking at the code, but I think if you delete a record it is marked as inactive by setting the first byte to 1. readRecord returns null if you read that inactive (deleted) record. I don't think readRecord is throwing a NullPointerException, I think it may be your code that is. If a method can return null, then you need to handle that when calling that method.
I never called delete in my application. Do your requirements specify that the user needs to delete records?
-BJ
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic