1
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();
}
}
沒有錯誤和編譯錯誤,SQLITE UDPATE或INSERT語句不想要執行
我不知道如果SQL語句的語法是正確的:混凝土:; ,但沒有編譯錯誤,插入和(可能更新)命令不會執行.... 我可以捕獲更多的細節?(sqlite statemenst)找出bug
你爲什麼使用'bindDouble'? –