android-SQLite插入引发语法异常

android-SQLite插入引发语法异常,第1张

概述我从SQLite收到此错误,靠近“,”:语法错误(代码1):,而在编译时:UPDATEOutfitItemSEToutfit_img_relative_pos_x=?,clothing_item_ID=?,outfit_img_relative_pos_y=?,outfit_img_relative_size_width=?,outfit_ID=?,outfit_img_relative_size_height=?WHERE(outfit_ID,cloth

我从sqlite收到此错误,

靠近“,”:语法错误(代码1):,而在编译时:

UPDATE OutfitItem SET outfit_img_relative_pos_x=?,clothing_item_ID=?,outfit_img_relative_pos_y=?,outfit_img_relative_size_wIDth=?,outfit_ID=?,outfit_img_relative_size_height=? WHERE (outfit_ID,clothing_item_ID) = (60,5)

有人可以为我找出错误吗?

以下是被编译的代码…

// ---updates a outfitItem---        public boolean update(long outfitID, long clothingItemID, double imgrelativePos_X, double imgrelativePos_Y,                double imgrelativeSize_wIDth, double imgrelativeSize_height)        {            ContentValues args = new ContentValues();            args.put(KEY_OUTFIT_ID, outfitID);            args.put(KEY_CLOTHING_ITEM_ID, clothingItemID);            args.put(KEY_OUTFIT_IMAGE_relative_POS_X, imgrelativePos_X);            args.put(KEY_OUTFIT_IMAGE_relative_POS_Y, imgrelativePos_Y);            args.put(KEY_OUTFIT_IMAGE_relative_SIZE_WIDTH, imgrelativeSize_wIDth);            args.put(KEY_OUTFIT_IMAGE_relative_SIZE_HEIGHT, imgrelativeSize_height);            return db.update(table_name, args, "(" + KEY_OUTFIT_ID + "," + KEY_CLOTHING_ITEM_ID + ") = (" + outfitID                    + "," + clothingItemID + ")", null) > 0;        }

以下是创建表的代码,并注意将外键设置为on …

public static final String table_name = "OutfitItem";        public static final String table_CREATE = "create table " + table_name + "(" + KEY_OUTFIT_ID                + " int not null REFERENCES " + table_Outfit.table_name + "(" + KEY_OUTFIT_ID + ") ON DELETE CASCADE,"                + KEY_CLOTHING_ITEM_ID + " int not null REFERENCES " + table_ClothingItem.table_name + "("                + KEY_CLOTHING_ITEM_ID + ") ON DELETE CASCADE, " + KEY_OUTFIT_IMAGE_relative_POS_X + " real not null, "                + KEY_OUTFIT_IMAGE_relative_POS_Y + " real not null, " + KEY_OUTFIT_IMAGE_relative_SIZE_WIDTH                + " real not null, " + KEY_OUTFIT_IMAGE_relative_SIZE_HEIGHT + " real not null, " + "primary key ("                + KEY_OUTFIT_ID + "," + KEY_CLOTHING_ITEM_ID + "));";

解决方法:

您的问题出在您的WHERE子句中:

WHERE (outfit_ID,clothing_item_ID) = (60,5)

这是无效的sql语法.您需要对AND联接使用单独的条件.

总结

以上是内存溢出为你收集整理的android-SQLite插入引发语法异常全部内容,希望文章能够帮你解决android-SQLite插入引发语法异常所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1210970.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-04
下一篇2022-06-04

发表评论

登录后才能评论

评论列表(0条)

    保存