Hi all.
I'm getting an error in a SELECT command from Sqlite DB.
The error msg is : "Error: SQLITE_ERROR: near "Index": syntax error"
The command I output to Sqlite DB:
var newMsg = {
// "topic": "SELECT * FROM MonthKwh ORDER BY Index DESC LIMIT 100"} *)
"topic": "SELECT * FROM MonthKwh ORDER BY Index DESC LIMIT 1"}
//"topic": "SELECT Month FROM MonthKwh"}
return newMsg;
The TABLE MonthKwh structure is:
CREATE TABLE MonthKwh
(
Index
INTEGER PRIMARY KEY AUTOINCREMENT,
Year
INTEGER,
Month
INTEGER,
XKwh
REAL,
FKwh
REAL
);
What I'm trying to do:
If the last row is in the same actual month, I want to overwrite this last row.
If the actual month is not the same of last row, then I need to INSERT a new row.
Thanks in advance.
Pau Torras