ios - sqlite 3 "SQL error 'out of memory' (7)" objc -
hi can point out i'm doing wrong please? error this:
sql error 'out of memory' (7) - (nsarray *)recipeinfo { nsmutablearray *retval = [[nsmutablearray alloc] init]; nsstring *query = [nsstring stringwithformat:@"select key, name recipes type = \'%@\'", self.recipetype]; nslog(query); sqlite3_stmt *statement; if (sqlite3_prepare_v2(_database, [query utf8string], -1, &statement, null) != sqlite_ok) { nslog(@"[sqlite] error when preparing query!"); nslog(@"%s sql error '%s' (%1d)", __function__, sqlite3_errmsg(_database), sqlite3_errcode(_database)); } else { while (sqlite3_step(statement) == sqlite_row) { int uniqueid = sqlite3_column_int(statement, 0); char *namechars = (char *) sqlite3_column_text(statement, 1); nsstring *name = [[nsstring alloc] initwithutf8string:namechars]; recipeinfo *info = [[recipeinfo alloc] initwithuniqueid:uniqueid name:name]; [retval addobject:info]; } sqlite3_finalize(statement); } return retval; }
the sql executes fine in database management environment use, has way i'm using sql api, can spot whats wrong?
you can error, confusingly, if neglected open database , pointer null
(or, rmaddy says, if it's null
reason). put log statement open database , make sure successful , have valid sqlite3
pointer.
Comments
Post a Comment