2016-12-05 7 views
0

SqlクエリがIOS 8.0 8.1で動作しておらず、IOS 8.2で動作しています 以下のsqliteクエリを見つけてください。sqlite iOS 8.0 - 8.1で動作していないクエリがIOS 8.2で動作しています。

-(BOOL)insertRecordsFromlastDateToCurrentDate{ 

    NSString *resultString = @""; 
    if(database == nil) 
    { 
     NSString *dbPath = [DatabaseHandler getDBPath]; 

     if (sqlite3_open([dbPath UTF8String], &database) != SQLITE_OK) { 

      NSAssert1(0, @"Error while opening Database. '%s'", sqlite3_errmsg(database)); 
      return nil; 
     } 

    } 
    NSString *queryString = [NSString stringWithFormat:@"WITH RECURSIVE dates(category, points,diagonisePoints, date) AS (VALUES('Healthy Weight', '0','0', (select DATE(selectedDate, '+1 day') as selectedDate from glanceTable ORDER BY ROWID DESC LIMIT 1)),('Healthy Diet', '0','0',(select DATE(selectedDate, '+1 day') as selectedDate from glanceTable ORDER BY ROWID DESC LIMIT 1)),('Exercise', '0','0',(select DATE(selectedDate, '+1 day') as selectedDate from glanceTable ORDER BY ROWID DESC LIMIT 1)),('Smoking Cessation', '0','0',(select DATE(selectedDate, '+1 day') as selectedDate from glanceTable ORDER BY ROWID DESC LIMIT 1)) UNION ALL SELECT category, points,diagonisePoints, date(date, '+1 day') FROM dates WHERE date < date('now')) insert into glanceTable SELECT category, points,diagonisePoints, date as selectDate FROM dates WHERE date <= date('now')"]; 

    const char *sql = [queryString cStringUsingEncoding:NSASCIIStringEncoding]; 
    sqlite3_stmt *selectstmt; 
    if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK) { 


     while(sqlite3_step(selectstmt) == SQLITE_ROW) { 
      resultString = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 0)] ; 
     } 
    } 
    return YES; 
} 

フィードバックには高く評価されます。

+0

エラー、警告? –

+0

@ Mr.Bistaエラーメッセージ: "WITH"構文エラー。 – kiran

答えて

1

私は、RECURSIVEキーワードがSqlite 3.8.3バージョンで導入されたことを念頭に置いています。したがって、iOS 8.0 8.1が古いsqliteバージョンで実行されている可能性があります。

関連記事:それはありません、古いバージョンのiOSの8.2からサポートさ

How to fix "near 'with': syntax error" in recursive CTE query (flask/sqlalchemy)

basic recursive query on sqlite3?

+0
+0

私は上記の質問をiOS 8.0と8.1で作ろうとしています – kiran

1

再帰クエリ。 あなたが再帰的にしたいのであれば、最小のosバージョンを8.2として設定する必要があります。

Androidでも再帰的にはLollipopより古いバージョンはサポートされていません...

+0

これは、iOS 8.2がSqliteのバージョンとは独立して再帰的クエリの内部サポートを持っていなかったことを意味します。 –

関連する問題