删除查询不起作用(db.delete、db.exectSQL、db.rawQuery...)
Delete query not working (db.delete, db.exectSQL, db.rawQuery....)
我正在尝试删除 Android 中 table 的某些行。我直接通过SQL命令"execSQL"和"rawQuery"尝试了运行。现在我正在使用 "db.delete" 我在参数 "where" 中介入我想删除的行。
这是代码:
String where = DBTables.TActivities.ID + " NOT IN ( " +
" SELECT " + DBTables.TInscripcionesActividades.ID_ACTIVIDAD + " FROM " +DBTables.TInscripcionesActividades.TABLE_NAME + " );";
db.beginTransaction();
db.delete(DBTables.TActivities.TABLE_NAME, where, null);
db.endTransaction();
我在 BBDD 浏览器中测试了 sql 请愿书,它运行良好。
我想删除 table "TActividades" 的所有记录,但 ID 在 "TInscripcionesActividades" table.
中的活动除外
有什么想法吗??提前致谢!
您需要在 endTransaction()
之前调用 setTransactionSuccessful()
以使更改生效。
String where = DBTables.TActivities.ID + " NOT IN ( " +
" SELECT " + DBTables.TInscripcionesActividades.ID_ACTIVIDAD + " FROM " +DBTables.TInscripcionesActividades.TABLE_NAME + " );";
db.beginTransaction();
db.delete(DBTables.TActivities.TABLE_NAME, where, null);
db.setTransactionSuccessful();
db.endTransaction();
我正在尝试删除 Android 中 table 的某些行。我直接通过SQL命令"execSQL"和"rawQuery"尝试了运行。现在我正在使用 "db.delete" 我在参数 "where" 中介入我想删除的行。
这是代码:
String where = DBTables.TActivities.ID + " NOT IN ( " +
" SELECT " + DBTables.TInscripcionesActividades.ID_ACTIVIDAD + " FROM " +DBTables.TInscripcionesActividades.TABLE_NAME + " );";
db.beginTransaction();
db.delete(DBTables.TActivities.TABLE_NAME, where, null);
db.endTransaction();
我在 BBDD 浏览器中测试了 sql 请愿书,它运行良好。
我想删除 table "TActividades" 的所有记录,但 ID 在 "TInscripcionesActividades" table.
中的活动除外有什么想法吗??提前致谢!
您需要在 endTransaction()
之前调用 setTransactionSuccessful()
以使更改生效。
String where = DBTables.TActivities.ID + " NOT IN ( " +
" SELECT " + DBTables.TInscripcionesActividades.ID_ACTIVIDAD + " FROM " +DBTables.TInscripcionesActividades.TABLE_NAME + " );";
db.beginTransaction();
db.delete(DBTables.TActivities.TABLE_NAME, where, null);
db.setTransactionSuccessful();
db.endTransaction();