【问题标题】:sqlite with iOS 5 issue带有 iOS 5 问题的 sqlite
【发布时间】:2013-04-04 16:10:49
【问题描述】:

好的,就是这样,我有以下查询

INSERT INTO 'FoodListTBL' ('AutoNo','CHOCals','PrtCals', 'FatCals','CHOgram','PrtGram','FatGram','CatId', 'TimeTypeId','TotalCals','Visibl', 'IsActive','NameAr','NameEn','CountryId', 'TotalPerUnit','UnitId','PreferedBread1', 'PreferedMilk1','PreferedVeg1','PreferedFat1', 'PreferedFruit1','CauseAllergy','AllergyCatId', 'TotalLikes','NameDescEn','NameDescAr','ChoPerUnit','PrtPerUnit','FatPerUnit','Quantity','PreferedBread2','PreferedMilk2', 'PreferedVeg2','PreferedFat2', 'PreferedFruit2','IV','UV','InsertDate','InsertUser') VALUES (818,0,0, 45, 0, 0, 5, 17, 1, 45,1, 1, 'زبدة قليلة الدسم', 'Butter reduced fat', 0, 45, 14, 0, 0, 0, 0, 0, 0, 0, 0, 'Butter reduced fat', 'زبدة قليلة الدسم', 0, 0, 45, 1, 0, 0, 0, 0, 0, 492, 0, '-', '-' ),(819,0,0, 45, 0, 0, 5, 17, 1, 45,1, 1, 'زبدة', 'Butter regular', 0, 45, 4, 0, 0, 0, 0, 0, 0, 0, 0, 'Butter regular', 'زبدة', 0, 0, 45, 1, 0, 0, 0, 0, 0, 493, 1475, '-', '-')

考虑到其他表上的任何其他插入查询在任何 iOS 上成功完成,此查询在 iOS 6.X 上成功执行,但在任何低于 5.X 的 iOS 上失败

我已经尝试了两个插入代码,这是其中之一

if(sqlite3_prepare_v2(database, [query UTF8String], -1, &compiledStatement, NULL) == SQLITE_OK) 
{   
    if(SQLITE_DONE != sqlite3_step(compiledStatement))
        NSLog( @"Error while inserting data: '%s'", sqlite3_errmsg(database));
    else NSLog(@"New data inserted");

    sqlite3_reset(compiledStatement);       
}else
{
    NSLog( @"Error while inserting '%s'", sqlite3_errmsg(database));
}
sqlite3_finalize(compiledStatement)

两种情况下的结果都是

插入'near ",":语法错误'时出错

除 iOS 之外,此查询的老化在所有事物上都可以使用

感谢任何线索

【问题讨论】:

    标签: ios ios5 sqlite


    【解决方案1】:

    3.7.11 之前的 SQLite 不支持多记录 INSERT 语法。

    使用多个INSERT 命令,或使用INSERT ... SELECT ... UNION ALL ... 插入记录。

    【讨论】:

    • 但是具有相同查询的相同代码在 iOS 6.0 上成功运行我没有用 iOS 6.0 更改 sqlite 版本
    • 我怎么知道我使用的sqlite版本,谢谢
    • 使用SELECT sqlite_version();;或者更好,只需使用适用于所有版本的表单即可。
    • 我使用的sqlite版本是3.7.13
    猜你喜欢
    • 2012-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多