如何在Objective-C中执行multiples sql

时间:2015-05-28 14:29:53

标签: ios objective-c sql-server

我有一个向量,我需要使用for来读取和执行sql查询这是我的代码:

for (int i=0; i < total; i++) {
    NSString *consultaRelacionEnvios;
    consultaRelacionEnvios = [[NSString alloc] initWithFormat:@"SELECT * FROM RELACIONENVIOS WHERE ID=%@",almacenIDAviso];
    SQLClient* client = [SQLClient sharedInstance];
    client.delegate = self;
    [client connect:URLConsulta username:@"usernameDB" password:@"passwordDB" database:nameDB completion:^(BOOL success) {
        if (success)
        {
             [client execute:consultaRelacionEnvios completion:^(NSArray* results) {
                 [self process0:results];
                 [client disconnect];
             }];
        }
    }];
}

- (void)process0:(NSArray*)data {
    for (NSArray* table in data)
        for (NSDictionary* row in table)
            for (NSString* column in row)
                [almacenRelacionEnvios addObject:row[column]];
    NSLog(@"%@",almacenRelacionEnvios);
}

0 个答案:

没有答案