我正在使用个人查询来更新表中的值,在这种情况下增加某些列的值。例如,我会做类似的事情:
UPDATE statistica SET 1PF = 1PF + ? WHERE id_statistica = ?;
我的代码如下:
String sql = "UPDATE " + StatisticaTable.TABLE_NAME + " SET " + StatisticaTable._1PF + " = " + StatisticaTable._1PF + " + ?, " +
StatisticaTable._1PN + " = " + StatisticaTable._1PN + " + ?, " +
StatisticaTable._2PF + " = " + StatisticaTable._2PF + " + ?, " +
StatisticaTable._2PN + " = " + StatisticaTable._2PN + " + ?, " +
StatisticaTable._3PF + " = " + StatisticaTable._3PF + " + ?, " +
StatisticaTable._3PN + " = " + StatisticaTable._3PN + " + ?, " +
StatisticaTable.RD + " = " + StatisticaTable.RD + " + ?, " + StatisticaTable.RO + " = " + StatisticaTable.RO + " + ?, " +
StatisticaTable.PR + " = " + StatisticaTable.PR + " + ?, " + StatisticaTable.AS + " = " + StatisticaTable.AS + " + ?, " +
StatisticaTable.BK + " = " + StatisticaTable.BK + " + ?, " + StatisticaTable.FS + " = " + StatisticaTable.FS + " + ?, " +
StatisticaTable.PP + " = " + StatisticaTable.PP + " + ?, " + StatisticaTable.FP + " = " + StatisticaTable.FP + " + ? " +
"WHERE " + GiocatoreTable.ID_GIOCATORE + "= ? AND + " + StatisticaTable.ID_PARTITA + "= ?;";
String[] parameter = new String[] {String.valueOf(values.get1pf()), String.valueOf(values.get1pn()), String.valueOf(values.get2pf()), String.valueOf(values.get2pn()),
String.valueOf(values.get3pf()), String.valueOf(values.get3pn()), String.valueOf(values.getRD()), String.valueOf(values.getRO()), String.valueOf(values.getPR()),
String.valueOf(values.getAS()), String.valueOf(values.getBK()), String.valueOf(values.getFS()),
String.valueOf(values.getPP()), String.valueOf(values.getFP()), String.valueOf(values.getIDGiocatore()), String.valueOf(values.getIDPartita())};
_dbHelper.getWritableDatabase().execSQL(sql, parameter);
本质上,代码是这样的......但没有更新任何东西(使用两个execSQL rawQuery),尽管参数传递正确并且sql字符串以正确的方式形成......我不明白什么是错的...... .