AndrewMozley
Programmer
We have a client who allocates account codes to his customers in the form Xnnn - so John Smith might have customer account S023, where the numeric part is the next available for the ‘S’ customers. This account number is printed on invoices &c.
One of the indexes on the customer table, XCUST, is this account code (there is also an index on the Unique ID).
When a new customer (Jones and company) is created we use the index on the XCUST table to find what the last used number was; we append a new record to the customer for account J123 (or whatever).
This has worked fine for years. Recently we noticed a problem that if the client deletes a customer (which can happen) who is the latest with his letter, and then create a new customer with that letter, the program uses the index to find the last used ‘J’ (which now appears to be J122) and try to create J123, there is an index violation.
There could be many ways of dealing with this - I believe we could :
* Change the index so that it only sees un-deleted records
* When creating a new account, check for deleted records and re-use the deleted one if it happens to exist.
There may be other ways, but I would hope not to have to re-write other parts of the system. Grateful for suggestions as to the best solution.
Thanks. Andrew
One of the indexes on the customer table, XCUST, is this account code (there is also an index on the Unique ID).
When a new customer (Jones and company) is created we use the index on the XCUST table to find what the last used number was; we append a new record to the customer for account J123 (or whatever).
This has worked fine for years. Recently we noticed a problem that if the client deletes a customer (which can happen) who is the latest with his letter, and then create a new customer with that letter, the program uses the index to find the last used ‘J’ (which now appears to be J122) and try to create J123, there is an index violation.
There could be many ways of dealing with this - I believe we could :
* Change the index so that it only sees un-deleted records
* When creating a new account, check for deleted records and re-use the deleted one if it happens to exist.
There may be other ways, but I would hope not to have to re-write other parts of the system. Grateful for suggestions as to the best solution.
Thanks. Andrew