Domanda

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.

È stato utile?

Soluzione

You could test for the existence of the table then branch accordingly:

SELECT DISTINCT tablename from sqlite_master where tablename = ?

Altri suggerimenti

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...
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top