Hi,

This does indeed work, but only to prevent primary keys from being
inserted into the database if they fall out of range.

What I was hoping was that the with this command, the sqlite3 would
always automatically choose primary keys that fell within this range.
However with this command, the sqlite3 will eventually automatically
choose a primary key outside of this range (I tested with a range of 100
to 1000), and fail to insert the new item based on the check clause.

I tried to repeat the statement hoping that a new primary key would be
generated and eventually the insertion would succeed, but this ended up
causing an infinite loop (I think the key once chosen by the automated
algorithm remains the same for repeated attempts).

Are there any alternatives? I want automatic key generation that is
restricted to a range, and I don't want failures unless all possible
values are taken. I will continue trying other things in the meantime.

Thanks,
Brett

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Sunday, January 14, 2007 6:09 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Restricting integer primary key values

"Brett Keating" <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I don't want to spam the list but basically, if "id INTEGER PRIMARY 
> KEY CHECK (id > 0 and id < 0xFFFFFFFF)" or something along those lines

> will work, please let me know. It's not clear if sqlite3 supports 
> checks on primary keys from what I can tell.
> 

SQLite does not support hexadecimal constants.  Use
4294967295 instead of 0xFFFFFFFF and it should work.
--
D. Richard Hipp  <[EMAIL PROTECTED]>


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




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

Reply via email to