0

When I initialize my Sqlite Database I make it as follows:

 var db = window.openDatabase("Database", "1.0", "Cordova Demo", 20000);
 db.transaction(populateDB, errorCB, successCB);
 function populateDB(tx) {
tx.executeSql('DROP TABLE IF EXISTS TimeTable');
tx.executeSql('CREATE TABLE IF NOT EXISTS TimeTable (id  INTEGER PRIMARY KEY      AUTOINCREMENT, Day, Subject, StartingTime, EndingTime)');}

Now, I don't want the table to be dropped every time I call this function. But when I remove this line:

tx.executeSql('DROP TABLE IF EXISTS TimeTable');

An error shows:

[INFO] Error processing SQL: 1

Is there a solution for this ?

Sana Joseph
  • 1,948
  • 7
  • 37
  • 58
  • I think you first need to delete table in database level.. and then run updated script, where you have commented `drop table` statement. – pratik garg Jul 10 '12 at 09:25
  • Where do I write the database level file ? – Sana Joseph Jul 10 '12 at 09:26
  • 1
    I was telling that first you have to delete this table from database, as it is already present in the database .. that's why I was thinking you should first clear the table from database.. But as you have `create table "if not exists"` then this thing is not required.. you can ignore last comment. – pratik garg Jul 10 '12 at 09:31
  • try this solution: http://stackoverflow.com/questions/9109438/using-already-created-database-with-android/9109728#9109728 – Yaqub Ahmad Jul 10 '12 at 09:36

1 Answers1

1

you can try the solution posted there:

phoneGap Android - Populate database once "Error processing SQL:1"

Community
  • 1
  • 1
Florian Brinker
  • 735
  • 7
  • 17