3

SQLiteからこのエラーが発生します。

near ",": syntax error (code 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;
        }

以下はテーブルを作成するコードであり、外部キーがオンに設定されていることに注意してください...

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 + "));";
4

2 に答える 2

4

あなたの問題はあなたのWHERE条項にあります:

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

これは有効なSQL構文ではありません。AND接続詞では個別の条件を使用する必要があります。

于 2012-10-02T12:16:49.860 に答える
0

@Neilが正しく指摘したように、次のコードを使用すると、機能し始めます

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 = 60 AND clothing_item_ID = 5;

于 2012-10-02T12:37:21.410 に答える