> Incorrect.  You can bind_int or bind_int64 on an integer primary key column
> just like any other column.
> What does sqlite3_errcode(db) and sqlite3_errmsg(db) say after you run
> sqlite3_step(pStmt) on the above?

I got "19 constraint failed" error from this code:

"CREATE TABLE functions ("
"        function_id integer PRIMARY KEY,"
"        function_name integer not null"
");\n"

...
  const char *sqlcmd;
  string strcmd, entryname;
  sqlite3_stmt *statement;

  strcmd = "INSERT INTO " + tablename + " VALUES(?,?)";
  sqlcmd = strcmd.c_str();
  if (sqlite3_prepare_v2(db, sqlcmd, -1, &statement, 0) != SQLITE_OK) {
    cout << "SQL error on " << sqlcmd << ": " << sqlite3_errmsg(db);
    sqlite3_close(db);
    exit(1);
  }

  for (int i=start_index; i<start_index+numentries; i++) {
    entryname = prefix + boost::lexical_cast<string>(i);
    str = entryname.c_str();
    sqlite3_bind_int(statement,0,i);
    sqlite3_bind_int(statement,1,i+10);
    if (sqlite3_step(statement) != SQLITE_DONE) cout << "SQL step error " << 
sqlite3_errcode(db) << " " << sqlite3_errmsg(db) << endl;
    sqlite3_reset(statement);
  }

  sqlite3_finalize(statement);

Thanks,
Bella
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to