Hi all

I need some help with SQLite Insert statement, I have a table called  
workout which has been created with the following definition

CREATE TABLE "Workout" ("workoutId" INTEGER PRIMARY KEY NOT  
NULL ,"historyId" INTEGER NOT NULL ,"latitude" DOUBLE,"longitude"  
DOUBLE,"vert_accuracy" DOUBLE,"hori_accuracy" DOUBLE,"distance"  
DOUBLE,"time" DOUBLE,"speed" DOUBLE);

in my app I have a class called Workout that has all the columns as  
above.

The goal is to insert into the Workout table about 1000 rows in one  
shot thru a loop, my problem is as soon as it reaches 250 the  
statement crashes with the following error:

**Terminating app due to uncaught exception  
'NSInternalInconsistencyException', reason: 'Error while inserting  
into Workout. 'not an error''
** I am using Objective-C


if i do less that 250 works fine, if I try 251 it crashes

here is my addWorkout method

- (void) addWorkout
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDire  
ctory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory  
stringByAppendingPathComponent:@"ibnr3.sqlite"];
// Open the database. The database was prepared outside the application.
if (sqlite3_open([path UTF8String], &db) == SQLITE_OK) {

if(addStatement == nil) {
const char *sql = "insert into Workout  
(historyId,latitude,longitude,vert_accuracy,hori_a  
ccuracy,distance,time,speed) Values(?,?, ?,?,?,?,?,?)";
if(sqlite3_prepare_v2(db, sql, -1, &addStatement, NULL) != SQLITE_OK)
NSAssert1(0, @"Error while creating insert statement. '%s'",  
sqlite3_errmsg(db));
}


sqlite3_bind_int(addStatement, 1, self.historyId);
sqlite3_bind_double(addStatement, 2, self.latitude);
sqlite3_bind_double(addStatement, 3, self.longitude);
sqlite3_bind_double(addStatement, 4, self.vert_accuracy);
sqlite3_bind_double(addStatement, 5, self.hori_accuracy);
sqlite3_bind_double(addStatement, 6, self.distance);
sqlite3_bind_double(addStatement, 7, self.time);
sqlite3_bind_double(addStatement, 8, self.speed);



if(SQLITE_DONE != sqlite3_step(addStatement))
NSAssert1(0, @"Error while inserting into Workout. '%s'",  
sqlite3_errmsg(db));

sqlite3_reset(addStatement);

}
else
{
sqlite3_close(db);

NSAssert1(0, @"Error opening database in Workout/AddWorkout. '%s'",  
sqlite3_errmsg(db));
}


}

do you guys see anything wrong in the method above, I am cluless

Any help on this is highly appreciated

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

Reply via email to