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

 

 

Reply via email to