-(NSMutableArray*) fetchMakeNamesYear1:(int) year1 Year2:(int) year2 compileStaement: (sqlite3_stmt*)compiledStatement
{
NSMutableArray *makeNames=[NSMutableArray array];
NSString *selectQuery=[NSString stringWithFormat:@"SELECT DISTINCT Make FROM Inventory WHERE [Year] BETWEEN 2009 AND 2012 AND Make IS NOT NULL ORDER BY Make",year1 ,year2 ];
// if (sqlite3_exec(((StorageManager*)[StorageManager sharedStorageManager]).database, [selectQuery cStringUsingEncoding:NSUTF8StringEncoding], NULL, NULL, NULL) == SQLITE_OK)
// {
//
// }
if(sqlite3_prepare_v2(((StorageManager*)[StorageManager sharedStorageManager]).database, [selectQuery UTF8String] , -1, &compiledStatement, NULL) != SQLITE_OK)
{
return nil;
}
while (sqlite3_step(compiledStatement) == SQLITE_ROW)
{
NSLog(@"return TYpe: %d",sqlite3_column_type(compiledStatement, 5));
if (sqlite3_column_text(compiledStatement, 5)!= NULL)
{
**NSString *makeName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 6)];**
[makeNames addObject:makeName];
}
sqlite3_reset(compiledStatement);
}
[self finalize:compiledStatement];
return makeNames ;
}SQL Query Предоставление NULL в качестве результата (Ожидание Текст)
Значение, возвращаемое sqlite3_column_text (compiledStatement, 5) является NULL.
В моей базе данных тип данных столбца № 5 - nvarchar [50].
Его имя столбца «Сделать»
Мое имя таблицы «Inventory»
В приведенном выше примере я HARDCODED значение и из года.
Я попробовал такой же sql-запрос в sqlite-менеджере, и обнаружил, что данные отображаются для всех имен. Я также обнаружил, что sqlite3_column_type (compileStatement, 5) Retuns 5 (SQLITE_NULL 5), но в соответствии с моей колонке типа должно быть 3 (SQLITE_TEXT 3)
Может кто-то дать представление о поведении выше?
Спасибо, я сделал здесь большую ошибку. Я понимал колонку в терминах индекса, в котором в самой таблице расположено другое поле. Сохранено мое время :) – Rahul