Click here to Skip to main content
15,882,329 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
An sqlite database should be created as soon as I run my application. I am getting an error near the create table statement saying TABLEtbl_Repair_Status: syntax error(code 1)...

My actual statement does not have any syntax errors, nor does it have that missing space the log cat is displaying.

Any idea what the problem might be ?
Posted
Updated 25-Jan-17 2:38am
Comments
CG0099 24-Jul-13 7:17am    
String createRepairStatus = "CREATE TABLE " + TABLE_REPAIR_STATUS + "(_id INTEGER PRIMARY KEY, status_name TEXT);";
ZurdoDev 24-Jul-13 8:09am    
I don't know sqlite but if it says there is a syntax error, I wouldn't argue with it.
CG0099 24-Jul-13 8:13am    
The comment I posted is the actual statement. There does not seem to be any syntax errors, I also tried removing all concatenations and hard-coded the whole statement. If there really is a syntax error, than I am not seeing it.

Try adding not null on your primary key:
C#
private static final String createRepairStatus = "CREATE TABLE " + TABLE_REPAIR_STATUS + "(_id INTEGER PRIMARY KEY NOT NULL, status_name TEXT);" ;
 
Share this answer
 
Comments
CG0099 24-Jul-13 8:59am    
Mehdi, thank you for your answer. Isn't a primary key set to not null by default?
Solved this question.

Tried closing down and re-opening Eclipse.
Java
..."CREATE TABLE" + TABLE_REPAIR_STATUS...
had no space after restarting, which I am positively sure was there before.

I hope this helps someone else too.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900