How to insert/update multiple record into SQLite database in a single query.

Posted by TuanCM on Stack Overflow See other posts from Stack Overflow or by TuanCM
Published on 2010-05-12T05:11:32Z Indexed on 2010/05/12 5:14 UTC
Read the original article Hit count: 301

Filed under:
|
|
|

Hi Guy.

Is it possible to insert/update multiple record in SQLite database using EGODatabase wrapper. If I'm correct I think we can do it with FMDatabase by wrapping it between [db beginTransaction] and [db commit]. I wonder if we can do the same thing by using EGODatabase.

Following is the code sample from FMDatabase project:

[db beginTransaction];
    i = 0;
    while (i++ < 20) {
        [db executeUpdate:@"insert into test (a, b, c, d, e) values (?, ?, ?, ?, ?)" ,
         @"hi again'", // look!  I put in a ', and I'm not escaping it!
         [NSString stringWithFormat:@"number %d", i],
         [NSNumber numberWithInt:i],
         [NSDate date],
         [NSNumber numberWithFloat:2.2f]];
    }
    [db commit];

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c