Note that there are some explanatory texts on larger screens.

plurals
  1. POfmdb(sql) strange error (iOS)
    primarykey
    data
    text
    <p>I got error:</p> <pre><code> Failed to insert row: Error Domain=FMDatabase Code=1 "table rss has 4 columns but 3 values were supplied" UserInfo=0x10914dc00 {NSLocalizedDescription=table rss has 4 columns but 3 values were supplied} </code></pre> <p>but I have 3 columns in my table:</p> <pre><code>CREATE TABLE "rss" ("name" VARCHAR PRIMARY KEY NOT NULL UNIQUE , "array" TEXT, "date" DATETIME) </code></pre> <p>"array" TEXT - stores array of 100+ text values</p> <p>to load and create base I use: </p> <pre><code> NSString *const kDatabaseFileName = @"rss.sqlite"; NSFileManager *fileManager = [NSFileManager defaultManager]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *databasePath = [documentsDirectory stringByAppendingPathComponent:kDatabaseFileName]; if (![fileManager fileExistsAtPath:databasePath]) { NSString *defaultDatabasePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:kDatabaseFileName]; [fileManager copyItemAtPath:defaultDatabasePath toPath:databasePath error:nil]; } FMDatabase *database = [FMDatabase databaseWithPath:databasePath]; if (![database open]) { database = nil; NSLog(@"Failed to open database"); } [FMDatabase setSharedInstance:database]; </code></pre> <p>to save my values in base I use:</p> <pre><code> FMDatabase *database = [FMDatabase sharedInstance]; NSMutableArray *parameters = [NSMutableArray arrayWithCapacity:10]; [parameters addObject:shortSelected]; [parameters addObject:_dataAll]; [parameters addObject:date]; //[parameters addObject:date]; BOOL updateResult = [database executeUpdate:@"INSERT OR REPLACE INTO rss VALUES ( ?, ?, ?)" withArgumentsInArray:parameters]; if (!updateResult) { NSLog(@"Failed to insert row: %@", [database lastError]); } NSInteger rowsCount = 0; FMResultSet *resultSet = [database executeQuery:@"SELECT COUNT(*) FROM rss"]; if ([resultSet next]) { rowsCount = [resultSet intForColumnIndex:0]; } </code></pre> <p>What is wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload