Reputation: 4695
I see that we cannot use "if not exists" in the create virtual table statement
CREATE VIRTUAL TABLE WORLD_LIST IF NOT EXISTS USING FTS3(_ID INTEGER PRIMARY KEY AUTOINCREMENT, WORD TEXT)
If I remove the IF NOT EXISTS
it works only once. Is there any alternative for this.
Upvotes: 0
Views: 1217
Reputation: 10720
It only works once because the table already exists the second time. You are receiving an error because of name conflicts. It is working as intended. Do you expect something different?
Not executing the statement would be a good option. Pushing the decision of whether or not to run that statement into the storage logic is not recommended.
If you are testing and want to recreate every time, then just drop the table.
DROP TABLE WORLD_LIST;
CREATE VIRTUAL TABLE WORLD_LIST USING FTS3...
Upvotes: 1
Reputation: 14472
You could test for the existence of the table then branch accordingly:
SELECT DISTINCT tablename from sqlite_master where tablename = ?
Upvotes: 1