3

I searched the hinted posts, when posting this question but I foud none similar, so I apologize if I missed any.

Here's my problem. I created a table and it's fields, in SQLite Administrator, then I wrote the following query to populate the table:

  USE Contact_Database;

  INSERT into Names (Contact_ID, FirstName, LastName) VALUES
  (1, 'Joana', 'Tavares'),
  (2, 'Patrícia', 'Dias'),
  (3, 'Paulo', 'Costa'),
  (4, 'Marco', 'Almeida'),
  (5, 'Bruno', 'Lindo'),
  (6, 'Manuela', 'Lindo'),
  (7, 'João', 'Lindo'),
  (8, 'Rui', 'Trindade');

Result error: SQL Error: near "USE": syntax error

I've also tried with:

  INSERT into Contact_Database.Names

Result error: SQL Error: near ",": syntax error <

What am I missing here?

csbl
  • 265
  • 1
  • 6
  • 19

2 Answers2

2

Multiple inserts in one query are not supported.

See this question for more information.

Community
  • 1
  • 1
Matt Beckman
  • 5,022
  • 4
  • 29
  • 42
  • Thank You!! It worked with the UNION SELECT! – csbl May 29 '12 at 03:58
  • The same is now happening but with creating a table... CREATE TABLE [Names] ( [Contact_ID] INTEGER DEFAULT 'None' NOT NULL PRIMARY KEY AUTOINCREMENT, [FirstName] CHAR(20) DEFAULT 'NULL' NULL, [LastName] CHAR(20) DEFAULT 'NULL' NULL ) – csbl May 29 '12 at 04:10
0

I had same problem but I solved it while I ignore (delete) the insertion query during creating table.

I changed this

db.execSQL("INSERT INTO MessageTable VALUES(datetime(),'Pir Fahim',00923359110795','Hello,testing');");

to:

db.execSQL("INSERT INTO CallTable VALUES('"+call_time+"','"+name+"','"+phone_no+"','"+interface_style+"','"+tone+"','"+voice_path+"','"+vibration_mode+"');");        
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Pir Fahim Shah
  • 10,505
  • 1
  • 82
  • 81