• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Checking for a deleted record

 
Robert Benson
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm working on the delete room functionality:

When a room is deleted, it is set to "1" or stored as 31 on file.

When I read back the file all the deleted rooms contain "31" in the expected position. When this is converted back the deleted field is 1 except for the last record which is -1. The last record fails my test to check if a room is deleted. However, if I check for the absolute value of deleted, it works fine. It works, but probably for the wrong reasons. I just want to check this is ok and not some dodgy code that will score badly.

I know its the last record, but I'm not reading the whole of the last record only a small portion of it so I wouldn't be expecting a -1 just yet.

This is a portion of my code:



regards, Robert.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Robert,

The length of the deleted flag in my assignment was also 1 byte. I use 0 for a valid record and 1 for a deleted record.

To read the deleted flag I use:

To write the deleted flag I use:

Never experienced a negative number for the deleted flag.

Kind regards,
Roel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic