我正在从 xcode 运行以下查询。但是,它没有返回任何结果。我很确定它应该返回结果,并且可以通过从 sqlite 浏览器运行相同的查询来确认相同的结果。然而,在 xcode 中, sqlite3_step 返回代码 101。我在这里做错了什么?
NSMutableArray *pages = [[NSMutableArray alloc] init];
char *query = " \
drop table if exists tempT; \
\
create temporary table tempT \
as \
select \
Page \
from \
( \
select 1 as Sort, 'Home' as Page \
union \
select 2 as Sort, 'Research' as Page \
union \
select distinct 3 as Sort, Category as Page from Researches \
union \
select 4 as Sort, 'Drafts' as Page \
union \
select 5 as Sort, 'Outbox' as Page \
union \
select 6 as Sort, 'Download' as Page \
union \
select 7 as Sort, 'Settings' as Page \
union \
select 8 as Sort, 'Deleted' as Page \
) as Sub \
ORDER BY Sort, Page \
; \
\
select Page from tempT order by rowid \
";
sqlite3_stmt *stmt;
if (sqlite3_prepare_v2(database, query, -1, &stmt, nil) == SQLITE_OK)
{
while (sqlite3_step(stmt) == SQLITE_ROW)
{
[pages addObject: [NSString stringWithUTF8String: (char *)sqlite3_column_text(stmt, 0)]];
}
sqlite3_finalize(stmt);
}
return pages;