Itzdsp
Itzdsp

Reputation: 912

Unable to insert 'NULL' as text in SQLIte

I am trying to insert text 'NULL' in SQLite table and getting syntax error near :'NULL'.

Below is my SQL insert statement.

db.execSQL("INSERT INTO POINTS_TABLE VALUES('NULL','NULL','NULL')");

Upvotes: 1

Views: 3180

Answers (1)

Mark Gilchrist
Mark Gilchrist

Reputation: 2032

I think you need to change your code from

db.execSQL("INSERT INTO POINTS_TABLE VALUES('NULL','NULL','NULL')");

to

db.execSQL("INSERT INTO POINTS_TABLE (COL1,COL2,Col3) VALUES ('NULL','NULL','NULL');");

further to this I think you want to loose the quotation marks unless you want to store the string "NULL" in these columns. if your data types for these columns are not strings then this will throw an error.

Upvotes: 1

Related Questions