Search code examples
objective-cios4sqlite

how to solve Error calling sqlite3_step (21: out of memory) rs in FMDB


i am using FMDB wrapper i used this code

- (BOOL)update:(NSString *) Body fromValue:(NSString *)froms {

    BOOL success = NO;
    FMResultSet *rs;
//I have **searchTable** and in that folder name **OFFICE**  

    rs = [self.database executeQuery:@"select searchId,body from searchTable WHERE folder = 'OFFICE'"];


    NSInteger primaryKey = -1;
    NSString *body = nil;
    NSString *md5OfSearchEmailBody = nil;
    while ([rs next]) {
        primaryKey  = [rs intForColumn:@"searchId"];
        body = [rs stringForColumn:@"body"];
    }           

    [rs close];
    return success;
}

first time

- (BOOL)update:(NSString *) Body fromValue:(NSString *)froms{
}

method working fine. in the loop second time it's not working

Error calling sqlite3_step (21: out of memory) rs

how to solve this problem


Solution

  • Check for the [rs close];

    May be it is releasing or closing the DB.

    ===================================================

    Better use CoreData to implement sqlite in your application.

    Why to use external library, when a better internal library is available in the Application. You don't need to remove your sqlite table. You can easily migrate your existing database to CoreData.