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);
Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
tilak
  • 4,589
  • 6
  • 34
  • 45
  • the query for inserting multiple sets of data is not correct.....i suggest to go through http://stackoverflow.com/a/5009740/1466009...it contains the exact query for inserting multiple set of data – aravind varma Aug 31 '12 at 05:24
  • 6
    I believe user fearless_fool already replied to that here: – goosfraba Mar 06 '13 at 14:40

2 Answers2

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);'; 
ЯegDwight
  • 24,821
  • 10
  • 45
  • 52
Daniel Jonker
  • 844
  • 10
  • 21
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?

Community
  • 1
  • 1
goosfraba
  • 80
  • 1
  • 8