1

I am developing a application for Android using PhoneGap. I am trying to insert multiple records to table in a single query using Javascript. I am getting a error like syntax error near ",".

My Code :

tx.executeSql('CREATE TABLE IF NOT EXISTS MAX_POINTS (Days INTEGER UNIQUE, Max_Point FLOAT)');      
sqlQuery = 'INSERT INTO MAX_POINTS(Days,Max_Point) VALUES(1,32),(2,35)';
tx.executeSql(sqlQuery);
2

2 Answers 2

1

Is it that you're missing the semicolon? Or that the values inserted into the float field are integers?

sqlQuery = 'INSERT INTO MAX_POINTS(Days,Max_Point) VALUES(1,32),(2,35)'; 

Should be:

sqlQuery = 'INSERT INTO MAX_POINTS(Days,Max_Point) VALUES(1,32.0),(2,35.0);'; 
Sign up to request clarification or add additional context in comments.

2 Comments

I have tried, same error am getting
have you tried putting a decimal on the max_points?
0

I believe user fearless_fool already replied to that here: Is it possible to insert multiple rows at a time in an SQLite database?

1 Comment

You should flag the question as duplicate rather than answering it with just a link.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.