#include <dbuniqueid.h>
Public Methods | |
DbUniqueId (const LookString &theName, const DbConnection *theConnection) | |
Constructor. More... | |
virtual | ~DbUniqueId () |
Destructor. | |
long | Generate (void) |
Get the next id. More... |
(this really belongs somewhere else)
Some databases provide a mechanism for providing unique numbers - eg SEQUENCES in Oracle. Some don't, and this can be used on these.
Concurrency may be an issue with this, so it needs thinking about before using on really big systems.
It relies on having a table 'control_fs' with columns 'name' (VARCHAR?) and 'next_number' (NUMBER/INTEGER?).
Each time a unique id is asked for for a name, the row in control_fs corresponding to that name is queried and the next_number incremented. The old next_number is returned. (If necessary, a new row is inserted into control_fs).
The insert/update is performed on a separate connection and hence transaction.
|
Constructor.
|
|
Get the next id.
|