阅读背景:

SQLITE UPDATE OR INSERT语句不想执行

来源:互联网 
public synchronized void saveMatchValue(int photoRecOwner,
        int[] photoRecAssign, float[] value) {
    SQLiteDatabase database = databaseHelper.getWritableDatabase();
    database.beginTransaction();
    String sql = " UPDATE " + TypeContract.CTablePhotoMatch.TABLE_NAME
            + " SET " + TypeContract.CTablePhotoMatch.VALUE + "=? "
            + " WHERE " + TypeContract.CTablePhotoMatch.FK_OWNER
            + "=? AND " + TypeContract.CTablePhotoMatch.FK_ASSIGN + "=? ;"
            + " INSERT OR IGNORE INTO "
            + TypeContract.CTablePhotoMatch.TABLE_NAME + "("
            + TypeContract.CTablePhotoMatch.FK_OWNER + ","
            + TypeContract.CTablePhotoMatch.FK_ASSIGN + ","
            + TypeContract.CTablePhotoMatch.VALUE + ") VALUES (?, ?, ?);";

    SQLiteStatement stmt = database.compileStatement(sql);

    try {

        int rows = photoRecAssign.length;
        for (int i = 0; i < rows; i++) {

            if (photoRecOwner > photoRecAssign[i]) {
                stmt.bindLong(1, photoRecOwner);
                // stmt.bindLong(index, value)
                stmt.bindLong(2, photoRecAssign[i]);

            } else {
                stmt.bindLong(1, photoRecAssign[i]);
                stmt.bindLong(2, photoRecOwner);

            }
            stmt.bindDouble(3, value[i]);

            stmt.execute();
            stmt.clearBindings();

        }
        database.setTransactionSuccessful();
    } finally {
        stmt.close();
        // updtStmt.close();
        database.endTransaction();
        // database.close();
    }
}
public synchronized void saveMatchValue(int pho



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: