this is my rawQuery
WITH authorRating(aname, rating) AS SELECT aname, AVG(quantity) FROM book GROUP BY aname
error is in Logcate
android.database.sqlite.SQLiteException: near "WITH": syntax error (code 1):
WITH is supported since SQLite 3.8.3, and that is not shipped with all Android versions.
Anyway, this query is not a valid WITH clause, and lacks the actual query.
Related
I'm trying to make a backup of a database in an Android application, and I was pointed to the VACUUM INTO query. However, when I try to call it, I get a syntax error around "INTO":
Caused by: android.database.sqlite.SQLiteException: near "INTO": syntax error (code 1 SQLITE_ERROR): , while compiling: VACUUM INTO 'Test'
The String itself:
String query = "VACUUM INTO 'Test'";
I've tried using double quotes, single quotes, different path names, .db, no file type, including and excluding the database name - always the same error.
Is INTO not supported on Android's implementation of SQLite?
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.
At the bottom of the documentation page you linked it states:
Note that the column-name list syntax is only supported in SQLite
versions 3.9.0 and later.
Version 3.9.0 is not supported by Android. Lollipop has 3.7.11. Marshmallow has 3.8.10.2.
Does ActiveAndroid not support the "not in" syntax in migrations?
Does ActiveAndroid not support subqueries in migrations?
I've run into exceptions like these when running migrations:
java.lang.RuntimeException: Unable to create application com.example.app.YourApp: android.database.sqlite.SQLiteException: not an error (code 0)
Or
java.lang.RuntimeException: Unable to create application com.example.app.YourApp: android.database.sqlite.SQLiteException: near "in": syntax error (code 1): , while compiling: delete from Collections where _id not in
The answer is that ActiveAndroid doesn't support something else (at least not currently): each migration statement must be ONE line, ending in a semicolon.
If you separate a sql query into multiple lines, ActiveAndroid will take only the first line, and give you different exceptions (such as the above) depending on where your query got cut off.
Save yourself some time and kill some readability: ActiveAndroid migrations cannot contain newlines (especially likely to run into this if you were trying to make subqueries readable).
I'm trying to get orders sorted by the customers delivery order.
This SQL statement works in my desktop database, but when I run it on the Android I get an error.
I tried using _id as well.
near "c": syntax error: , while compiling: SELECT * FROM Orders o,
Customer c WHERE o.Route='My Route' c.id=o.Customernum ORDER BY
c.StopNum
Your SQL statement is missing an AND:
SELECT * FROM Orders o, Customer c WHERE o.Route='My Route' AND
c.id=o.Customernum ORDER BY c.StopNum
I am getting an SQL syntax error but I'm not quite sure why. This is the error code I am obtaining;
android.database.sqlite.SQLiteException: near "GCSE": syntax error (code 1): , while compiling: SELECT foreign_word,english_meaning,correct FROM vocab_words WHERE name = AQA GCSE Spanish Higher
Any suggestions to fix this - I don't know what the error is?
when the column's data type is string, its value should be wrapped with single quote.
SELECT foreign_word,english_meaning,correct
FROM vocab_words
WHERE name = 'AQA GCSE Spanish Higher'