1

If I use the below code:

var db = openDatabase("CurrADinfo", "1", "A list of QC Points.", 100000);
db.transaction(function (tx) {
     tx.executeSql('CREATE TABLE foo (id , text)');
});

It will create or open the database CurrADinfo if it exists. But the second line will always create a new table.

I want to create a table once and next time when I try to create it should return a flag that it is found in the database. How can I do that?

2
  • openDatabase will open the database if it exists, or create a new one if it does not. I'm not sue what you need past that. Commented Dec 15, 2011 at 14:28
  • I'm not sure what this question has to do with HTML5. Help me out? Commented Oct 3, 2012 at 16:58

1 Answer 1

2

If I understand your question (which isn't completely clear to me), you need to create a table if one doesn't already exist:

tx.executeSql('CREATE TABLE IF NOT EXISTS foo (id , text)');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.