• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

delete method

 
Lee Sunter
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the database interface
// Deletes a record, making the record number and associated disk
// storage available for reuse.
public void delete(int recNo) throws RecordNotFoundException;

but later its says
'Any methods that throw RecordNotFoundException should do so if a specified record does not exist or is marked as deleted in the database file'

I have just been marking the records as deleted when I delete them as that is how they have been givenm to me in the data file
'2 byte flag. 00 implies valid record, 0x8000 implies deleted record'

Just thought I would ask what people thought?

Thanks
Lee
(ps whats the String value of 0x8000?)
 
Sravan Kumar
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before deleting a record, check if a record exists at the given number. You can do this by analyzing the two-byte pattern.

If a record exists, the byte pattern will be 0000000000000000. Delete the record and mark the two-byte pattern as ox8000. Else, throw a RecordNotFoundException.
 
Lee Sunter
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, once again sorry if I am being slow but how would one mark the record as deleted is it a case of puting an Integer with a value of 1 at the front as the data file i have has no examples and the active files are all 00 at the front?
Thank
Lee
 
Tim Fernandez
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Lee Sunter:
Thanks, once again sorry if I am being slow but how would one mark the record as deleted is it a case of puting an Integer with a value of 1 at the front as the data file i have has no examples and the active files are all 00 at the front?
Thank
Lee



shouldn't it be just like this:


 
Oricio Ocle
Ranch Hand
Posts: 284
Debian Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,
maybe this link could be interesting...

Code Conventions

and necessary for passing the SCJD exam, dont you think?

Regards
[ September 27, 2005: Message edited by: Oricio Ocle ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic