1
votes

I am trying to execute this statement in mozilla sqlite add-on

alter table (select tbl_name from sqlite_master where rowid=1) add  GUID varchar

But this runs into error :

SQLiteManager: Likely SQL syntax error: alter table (select tbl_name from sqlite_master where rowid=1) add GUID varchar [ near "(": syntax error ] Exception Name: NS_ERROR_FAILURE Exception Message: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [mozIStorageConnection.createStatement]

the statement :select tbl_name from sqlite_master where rowid=1 works fine

1

1 Answers

1
votes

You cannot do that: in SQL, table names and column names must be identifiers embedded in the SQL string itself. They cannot come from values that you query, or even in a query parameter.

You need to select the table name, make the alter table statement, and then execute it separately.