1
我在我的代碼集成FMDB庫,我嘗試在單一功能加載多個查詢,但我收到了一些問題FMDB - 錯誤調用sqlite3_step(21:內存不足)RS
* Error calling sqlite3_step (21: out of memory) rs
* FMDB not open
* FMDB is in use
是否有可能要在單個函數中運行多個查詢?請讓我知道您的意見。
由於提前
我想這FYI:
-(NSMutableArray *)getMyInfo
{
NSMutableArray *contactList = [NSMutableArray array];
if(![instance.database open])
{
DLog(@"Could not open DB");
return nil;
}
********** QUERY 1 **************
FMResultSet *resultSet=[instance.database executeQuery:@"SELECT * FROM mycontacts WHERE cont_hidden = 0 and cont_recent_chat_time IS NOT NULL ORDER BY strftime(cont_recent_chat_time) DESC"];
if(resultSet)
{
while([resultSet next])
{
@autoreleasepool
{
int type = [resultSet intForColumn:@"contact_type"];
Contactbean *contactObj = [[Contactbean alloc]init];
[contactObj setPhoneNo:[resultSet stringForColumn:@"cont_phonenumber"]];
********** QUERY 2 **************
FMResultSet *getCountResult=[instance.database executeQuery:@"SELECT count(kchatid) FROM mychat WHERE kisread = 0 and kchatnumber = ?",[resultSet stringForColumn:@"cont_phonenumber"]];
if ([getCountResult next]) {
if([getCountResult intForColumnIndex:0] > 0)
{
[contactObj setCount:[getCountResult intForColumnIndex:0]];
}
}
[getCountResult close];
********** QUERY 3 **************
FMResultSet *getRecentResult=[instance.database executeQuery:@"SELECT * from mychat where kchatnumber =? AND kchattime =?",[resultSet stringForColumn:@"cont_phonenumber"],[resultSet stringForColumn:@"status"]];
if([getRecentResult next])
{
[contactObj setStatus:[getRecentResult intForColumn:@"status"]];
}
[getRecentResult close];
// Adding contact to the list
[contactList addObject:contactObj];
}
}
}
[resultSet close];
[instance.database close];
return contactList;
}
THX兄弟!爲我工作 – Jerome