Hopefully not too obvious questions, but do all your tests use the same values 
in the list array?  What is the value of list[i] when you get the 
SQLITE_CONSTRAINT error?  Are you confirming that the value of list[i] is in 
fact not somewhere earlier in the array? Any chance a NULL is creeping in to 
list[i]?

Is the table empty before you rn the tests?

The code looks okay, so my gut instinct would be to look at the data being fed 
in to see if that is causing the problem.

David



--- On Sun, 3/16/08, Vincent Vega <[EMAIL PROTECTED]> wrote:

> From: Vincent Vega <[EMAIL PROTECTED]>
> Subject: Re: [sqlite] SQLITE_CONSTRAINT error after sqlite3_step
> To: [EMAIL PROTECTED], "General Discussion of SQLite Database" 
> <[email protected]>
> Date: Sunday, March 16, 2008, 4:37 AM
> Sorry.. I didn't copy it correctly..
> Anyhow, as I said before the code works fine most of the
> times(I can insert 500 records to the table and read them
> correctly) but from time to time I get SQLITE_CONSTRAINT
> error code after the sqlite3_step.
> Any Idea why?
> 
> Here are the table defenitions :
> CREATE TABLE 'Inventory' (
> 'TagIndex' integer PRIMARY KEY,
> 'Tag' varchar(12) NOT NULL,
> ) ;
> 
> CREATE UNIQUE INDEX InventoryIndex ON Inventory (Tag);
> 
> My code looks like this:
>  
> query = sqlite3_mprintf("Insert into Inventory (Tag)
> values (?)");
> rc=sqlite3_prepare_v2(DB,query ,-1,&Statement,NULL);
> if (rc!=SQLITE_OK)
>     error_print();
> sqlite3_exec(db,"BEGIN;",NULL,NULL,&err);
> for (i=1;i<500;i ++)
> {
>     rc=sqlite3_bind_text(Statement,1,list[i],-1,NULL);
>     if (rc!=SQLITE_OK)
>         error_print();
>     rc=sqlite3_step(Statement);
>     if (rc!=SQLITE_DONE)
>         error_print();
>     sqlite3_reset(Statement) ;
> }
> sqlite3_finalize(Statement) ;
>  
> sqlite3_exec(db,"END;",NULL,NULL,&err) ;
> 
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to