finite numbering system to keep in order

  • Thread starter Thread starter bthumber
  • Start date Start date
B

bthumber

I need to write a method that reads though numbers in a database. The
numbers are appended to a records name. Each location can have one name many
records. Example: buff01, buff02, buff03...buff100. Only 01 to 100. If the
user deletes a record said buff20, there will be a gap between buff19 and
buff21. The next time a record is created the program should see the gap and
append 20 to buff the end result will be buff20. Any ideas, any sudo code to
get me statrted???
 
I need to write a method that reads though numbers in a database.  The
numbers are appended to a records name. Each location can have one name many
records. Example: buff01, buff02, buff03...buff100.  Only 01 to 100.  If the
user deletes a record said buff20, there will be a gap between buff19 and
buff21.  The next time a record is created the program should see the gap and
append 20 to buff the end result will be buff20.  Any ideas, any sudo code to
get me statrted???

The most obvious way would be to not delete the records, but just to
mark them deleted (alternatively, you may have a separate table to
keep track of unused numbers). Then, whenever a new record is created,
you just pick the lowest unused ID (and mark it as no longer unused).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top