Jump to content

Sequential Numbering out of sequence


coolego1

Recommended Posts

Hello,

I am working on an inventory system where an item may come in out of order from the rest of its fellow objects.  For instance, there could be item #1, item #2, item #5 and item #6.  If a new item shows up, it should receive number 3.  The next item should get number 4.  After that the numbers would be 7,8,9 as you would expect...  I'm sure there is code to check this nicely, but I don't know how to write it.  Any suggestions?

Link to comment
Share on other sites

I guess I didn't clarify.  I want the numbers to always be less than 100.  The numbers will be stored in a database, but the number only has 2 spots to be in (it's the end of an item number) so the number must remain less than 100.  If an item is thrown out, its number will be released to be reused.

Link to comment
Share on other sites

that is easy if you just query for the id and the first output will perform the condition like

when first minus second is >=1 or then insert the id as your desired number

 

output1 -  output2

output2 - output3

 

i just give the logic hope you get it

Link to comment
Share on other sites

OK, this is the system.

 

I have a warehouse full of stuff.  The stuff has an item ID on it.  Each item ID is 6 characters long.  The First 4 characters of the ID are used to identify the type of item.  The last 2 numbers are unique to each item.  In conjunction with the first 4 characters, the last 2 create a completely unique ID.  I don't want to waste any of my numbers for these last 2 (because they can only be 00 to 99) and so if an item is thrown out, its ID number can be reused.  I would like to keep track of all these unique numbers in a database and when new items come in, generate new 6 digit IDs for them.  As I said, if numbers are:

 

AB1402

AB1403

AB1406

AB1407

...

AB1499

 

There are numbers 01, 04, and 05 in there that can be reused.  How can I decide that these numbers are reusable without a massive for loop?

Link to comment
Share on other sites

Well, this is a new system that is coming in on top of a pencil and paper system, so the items are already numbered.  So as not to disturb the order of the universe in the warehouse, the numbering scheme needs to remain consistent...

 

My ultimate question is: Is what I'm asking for possible?

Link to comment
Share on other sites

yes, but the same can be accomplished adding a leading 0 to preexisting numbers and simply cropping it out for items already made.  Is your idea practical no because it will end up causing you headaches down the road with cached data (including paper results)  You learn really quickly 100 items isn't going to be enough and reusing numbers is a poor idea in generally because an item number is like a primary key.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.