mardi 1 décembre 2015

Why do I get SQL syntax error when creating a view?

Developing an Android app, but this is a SQLite question.... My SQL is much ropier than my Java.

This is the SQL (copied from a log file, in code it's constructed from various constants):

CREATE VIEW albums (_id, name , type ) AS SELECT rowno, name, subtype   FROM metadata WHERE subtype = 'album'

but it throws:

android.database.sqlite.SQLiteException: near "(": syntax error (code 1): , while compiling:

Specifying column names in the view seems to me to be clearly permitted, if I understand the flow chart in the sqlite documentation here, and at this time of night I really can't see what's wrong. I have tried changing the name of the _id column in case it was something to do with the initial underscore, but to no avail and in any case I will need the _id column later for the CursorAdapter that will end up using this View.

Aucun commentaire:

Enregistrer un commentaire