On 31 Aug 2011, at 4:55am, Tarun wrote:

> Is there any configurable parameter which allows us to set maximum
> number of records that is allowed to be inserted. Once this limit is
> reached, insert SQL query should fail inserting records telling max
> records have been inserted in DB table.

sqlite> CREATE TABLE testTable (id INTEGER PRIMARY KEY CHECK (id <= 5), name 
TEXT);
sqlite> INSERT INTO testTable (name) VALUES ('Frederick');
sqlite> INSERT INTO testTable (name) VALUES ('Mabel');
sqlite> INSERT INTO testTable (name) VALUES ('Cuthbert');
sqlite> INSERT INTO testTable (name) VALUES ('Maud');
sqlite> INSERT INTO testTable (name) VALUES ('Reginald');
sqlite> INSERT INTO testTable (name) VALUES ('Flora');
Error: constraint failed

You should, of course, be handling errors in your own code and since you can 
placed only one constraint on this table, you can assume that a constraint 
failure means you've reached the maximum id.

You do need to consider quite carefully what happens if a record is DELETEd, or 
whether your understanding of the data would ever allow this to happen in the 
first place.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to