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) ;


 
----- Original Message ----
From: Jay A. Kreibich <[EMAIL PROTECTED]>
To: General Discussion of SQLite Database <[email protected]>
Sent: Saturday, March 15, 2008 3:07:46 AM
Subject: Re: [sqlite] SQLITE_CONSTRAINT error after sqlite3_step

On Fri, Mar 14, 2008 at 04:09:50PM -0700, Vincent Vega scratched on the wall:


> for (i=1;500;i ++)
> {

  I can't say about your CONSTRAINT problem, but that's an infinite loop.
  And 1?  Seriously?




  Without a full description of the table and all the indexes on the
  table (and, if possible, real data values), it is difficult to say
  what the problem is.  CONSTRAINT issues are normally data issues,
  not code problems.

  -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"'People who live in bamboo houses should not throw pandas.' Jesus said that."
  - "The Ninja", www.AskANinja.com, "Special Delivery 10: Pop!Tech 2006"
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


      
____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to