Phani,

Read the "auto increment" in Sqlite FAQ s it is the first one in the list,
it will solve your problem.


Best Regards,
A.Sreedhar.
 
-----Original Message-----
From: B V, Phanisekhar [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 30, 2007 2:11 PM
To: sqlite-users@sqlite.org
Subject: [sqlite] How to generate Unique ID?

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