ISSUE:
[ INFOTABLE ]
with a timestamp column named DATETIMESTAMP
[INTEGER] datatype.2020-01-01T17:45:31.127452+03:00[Asia/Riyadh]
SQLITE TABLE:
String create_sql3 = "CREATE TABLE IF NOT EXISTS " + Tablename3 + "("
+ SNO + " INTEGER NOT NULL," + ITEM + " INTEGER NOT NULL,"
+ DATETIMESTAMP + " INTEGER DEFAULT CURRENT_TIMESTAMP )";
DELETE QUERY:
db.execSQL("DELETE FROM " + Tablename3 + " WHERE DATETIMESTAMP = " + Integer.parseInt(deltimestamp.get(y)) + ";");
EXCEPTION LOGGED:
android.database.sqlite.SQLiteException:
unrecognized token: "01T17" (code 1):,while compiling: DELETE
FROM INFOTABLE WHERE DATATIMESTAMP = 2020-01-01T17:45:31.127452+03:00[Asia/Riyadh];
Here deltimestamp
is a String Arraylist which has datetimestamps as String. Appreciate help on Delete query correction for CURRENT_TIMESTAMP
column!
Fixed the issue!
QUERY (ERROR):
db.execSQL("DELETE FROM " + Tablename3 + " WHERE DATETIMESTAMP = " + Integer.parseInt(deltimestamp.get(y)) + ";");
QUERY (FIXED):
db.execSQL("DELETE FROM " + Tablename3 + " WHERE DATETIMESTAMP = " + "'" + deltimestamp.get(y) + "'" + ";");
OR
db.execSQL("DELETE FROM " + Tablename3 + " WHERE DATETIMESTAMP = "+ "'" + cursor.getString(7) + "'" + ";");