QUOTE
I think they were confused when you mentioned auto-increment. The application here is that the InvoiceID field is DIFFERENT from the InvoiceNumber. This is a totally acceptable way to set up your database schema. The application here is that the user may not enter the invoice numbers in order (for various reasons such as pending order which was mentioned earlier). This means the InvoiceNumber field CANNOT be auto-incremented.
No confusion about it whatsoever. I understood completely what he wanted. What I didn't understand (and still don't) is the absolute requirement that the invoice number be allowed to be issued in such a haphazard fashion as manually inputting manually created Invoice numbers which are input in random order on a sporadic basis. And then wanting to know which ones were missing. There is a completely different use for the 'Sequence number' of the database, I agree.
This goes beyond the actual coding of this problem. It has to do with the systemic problem of Invoice Control and regulation of the Invoice Numbering system. I have worked at Companies which produce an Invoice Number based on an alphabetic system , not numeric at all, and could still tell you when one was missing or out of place. And your code will only work with truly sequential numeric values, by the way.
There may be valid reasons why the Invoice number MUST be issued manually. That is an Accounting System decision. Let the programmer sort out how to track them after that. There doesn't need to be an accountant involved in writing the code, is all I am saying. Use the auto increment feature of the database to track the Invoices 'sequentially' regardless of what the 'number' is on the piece of paper you hand the Customer. There need not be a relationship between the 'auto-increment' number and the 'Invoice' number. In fact, then you have the accounting system meddling in affairs they know nothing about. Trust me, I've been there before. You will find that the 'sequencing' problem will be difficult enough to deal with. Even harder will be a duplicate number.



