Why do you have a unique primary key as an integer to hold your other unique integer? Why not just use the unique integer as a primary key?

If you want to have a limit on the maximum unique ID you can store your next to allocate and next to replace keys in another table.

B V, Phanisekhar wrote:
Assume I have a table:

Create table YYY (id Interger PRIMARY KEY, puid Unique integer)

Id is the primary key.

Puid is an unsque interger, whose values needs to be assigned by the
user.

Currently my approach is get the maximum value of puid stored in the
table; add 1 to it and uses this value as puid for any new row that
needs to be added. The problem occurs when I reach the max value.
Meanwhile, some rows might have been deleted. In case, when I reach the
maximum value I want to reuse the puids of the deleted rows for new rows
that are to be added. Currently SQLite uses some algorithm to generate a
unique rowid (even when it reaches the limit). I want to use the same
algorithm here also. I tried to understand the algorithm but couldn't. I
need a simple way by which I can generate a unique puid without writing
the algorithm.

Regards,

Phani




-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to