sqlite Query 在 iOS 8.0 - 8.1 和 IOS 8.2 中不起作用 [英] sqlite Query is not working in iOS 8.0 - 8.1 and working in IOS 8.2

查看:41
本文介绍了sqlite Query 在 iOS 8.0 - 8.1 和 IOS 8.2 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Sql Query 在 IOS 8.0 8.1 和 IOS 8.2 中不起作用请找到下面的 sqlite 查询.

Sql Query is not working in IOS 8.0 8.1 and working in IOS 8.2 Please find the below sqlite query.

-(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;
}

非常感谢您的反馈.

推荐答案

旧版本的 iOS 8.2 不支持递归查询.如果您想要递归,则可以根据您的要求将最低操作系统版本设置为 8.2.

Recursive query supported from iOS 8.2 in older version it is not there. Its on your requirement if you want recursive than you have to set minimum os version as 8.2.

在 Android 中,Recursive 也不支持比 Lollipop 更旧的......

In Android also Recursive is not supporting older than Lollipop...

这篇关于sqlite Query 在 iOS 8.0 - 8.1 和 IOS 8.2 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆