Please let me know how to insert arrays into the Sqlite table. I am passing 2 arrays as the parameter. Here is the code:
-(void)saveData:(NSMutableArray *)firstArray second:(NSMutableArray *)secondArray {
[self openDB];
NSString *createSQL = @"CREATE TABLE IF NOT EXISTS Table1"
“(EID INTEGER PRIMARY KEY, Array1 TEXT, Array2 TEXT);";
char *errorMsg;
if (sqlite3_exec (database, [createSQL UTF8String],
NULL, NULL, &errorMsg) != SQLITE_OK)
{
sqlite3_close(database);
NSAssert(0, @"Error creating table: %s", errorMsg);
}
char *update = "INSERT OR REPLACE INTO Table1 (ID, Array1, Array2)"
"VALUES (?, ?, ?);";
errorMsg=NULL;
sqlite3_stmt *stmt;
if (sqlite3_prepare_v2(database, update, -1, &stmt, nil)
== SQLITE_OK) {
Please let me know how to insert the data.
if (sqlite3_step(stmt) != SQLITE_DONE)
NSAssert(0, @"Error updating table: %s", errorMsg);
sqlite3_finalize(stmt);
}
}