lundi 12 octobre 2015

Insert boolean value into sqlite table

I created a table MYTABLE

CREATE TABLE "MYTABLE" (
       "surname" VARCHAR,
       "name" VARCHAR,
       "id" INTEGER PRIMARY KEY  NOT NULL ,
       "flag" BOOL);

when I insert a record with:

INSERT INTO "MYTABLE" VALUES ("Super","Mario","94", true);

I get an error message, that no such column: true. If I use this:

INSERT INTO "MYTABLE" VALUES ("Super","Mario","94", "true");

I don't get any error, but when i read that record with rs.getBoolean("flag") I get false.

Finally, i tried this

INSERT INTO "MYTABLE" VALUES ("Super","Mario","94", 1); 

the rs.getBoolean("flag") returns true. So the lesson here is that the boolean values in Sqlite are inserted with 0/1 ?

Aucun commentaire:

Enregistrer un commentaire