Search code examples
objective-cfmdb

FMDB Update query not working


I have an FMDB update query that is not working. Here is my code:

FMDatabase *db = [self openDatabase];

if (![db open]) {
    return;
}

NSString *updateMeeting = [NSString stringWithFormat:@"UPDATE meetings SET MEETING_DESCRIPTION=\"%@\" WHERE MEETING_ID=\"%@\"",meeting.meetingDescription, meeting.meetingId];

[db beginTransaction];
[db executeQuery:updateMeeting];
[db commit];
[db close];

These are the things i've checked:

  1. The properties I pass are objects and are not nil.
  2. Some places online use \"%@\", some use '%@', some use %@ and some use ?. None of which worked for me.
  3. I NSLoged my string and it looks like this:

    UPDATE meetings SET MEETING_DESCRIPTION="AAA12" WHERE MEETING_ID="791D8251-2FC4-498B-85B3-C1002C04E329:F1C40061-1308-4179-B72E-7E3EEDB85E1A"
    
  4. I thought maybe my data base cant find this meetingID so I ran a SELECT query for this messageID and found it.

I'm pretty much hopeless. Can anyone think of something i haven't tried?

Thanks


Solution

  • Ok guys,

    I found the answer thanks to my colleague.

    The method [db executeQuery:updateMeeting] is wrong, instead you should use [db executeUpdate:updateMeeting];

    This is annoying cause I thought that Update is also a query but what the hack... It works now :)