1

I use sql query to insert data into database, everything work fine if i insert just one record into table,here is my code

1. setData("insert into table(name,age) values ('john','23')");

code for insert data above succesful saved in database, but I if i use this code bellow

2. setData("insert into table(name,age) values ('john','23'),('jane','20'),('mraz','21'),('albert','12'),('josh','23')");

and methode for insert like this

public String setData(String sql){
      ourDatabase.execSQL(sql);
  return "success";
}

if i use code no 1, data successfull inserted but if i use code no 2 it fail. here log for code no 2

Failure 1 (near ",": syntax error) on 0x24b900 when preparing 'insert into table(name,age) values ('john','23'),('jane','20'),('mraz','21'),('albert','12'),('josh','23')'.

what wrong with code no 2 ? if i try use code no 2 in mysqlfront or phpmyadmin without throught android is work fine,and second problem is,if i run in jellybean data succesfull inserted into database,but if i run in gingerbread code no 2 trouble?

CL.
  • 173,858
  • 17
  • 217
  • 259
ltvie
  • 931
  • 4
  • 19
  • 48
  • You can find more information here: http://stackoverflow.com/questions/1609637/is-it-possible-to-insert-multiple-rows-at-a-time-in-an-sqlite-database – Jelle Aug 13 '14 at 07:27
  • Search thuis site and find sqlite specific version requirement and syntax – Pieter21 Aug 13 '14 at 07:38

1 Answers1

0

The multiple values in insert syntax was introduced in sqlite 3.7.11.

Older Androids are running older versions of sqlite.

Community
  • 1
  • 1
laalto
  • 150,114
  • 66
  • 286
  • 303