Tuesday, 17 September 2013

SQLite (and Android, sorry to be a cleche) is `in` a valid column name?

SQLite (and Android, sorry to be a cleche) is `in` a valid column name?

it's a short one, I've spent 10 minutes checking spellings and such but I
cannot find an error!
So I am wondering is "in" a valid column name in SQLite? I usually use
MariaDB (MySQL but with that old spirit and no Oracle) and provided one
escapes/uses statements properly all is usually well.
09-18 03:15:27.892: E/SQLiteLog(30043): (1) near "in": syntax error
09-18 03:15:27.892: E/SQLiteDatabase(30043): Error inserting state=1
time=1378810407
reading=13964 in=0
09-18 03:15:27.892: E/SQLiteDatabase(30043):
android.database.sqlite.SQLiteException:
near "in": syntax error (code 1): , while compiling: INSERT INTO
Readings(state,time,reading,in) VALUES (?,?,?,?)
Helpful right?
-- Describe READINGS
CREATE TABLE "Readings" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"reading" INTEGER,
"in" INTEGER,
"time" INTEGER,
"state" INTEGER
)
Use:
ContentValues values = new ContentValues();
values.put("reading", reading.asInt());
values.put("in", in.asInt());
values.put("state",State.OKAY.ordinal());
values.put("time", time.getTimestamp());
return (int) db.insert("Readings", null, values);
In is actually 0 btw, I have a whole heap of errors, some with different
in values. There are no type errors or silenced exceptions.
I did want to put "just a short one" but then I thought "No, they'll want
more" so sorry "it's a short one" turned out to be a lie.
Please do help, I didn't expect any errors, and I am not even sure what's
wrong.

No comments:

Post a Comment