ActiveAndroid migration not an error (code 0), syntax error - android

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).

Related

Syntax Error using Vacuum Into on Android

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?

"WITH" clause Query not working in android

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.

Android Database Sugar orm no such table

i'm working on a project in android ! And i use Sugar ORM for the interaction with my database.But i think sugar become crazy sometimes. I have an error No such Column while compiling.I dont understand ! Anywhere in the code I put it.
public List<Plats> getAllplatById(){
return Plats.find(Plats.class ,NamingHelper.toSQLNameDefault("id_menus")+"= ?" ,String.valueOf(id));
}
And i got this error :
Caused by: android.database.sqlite.SQLiteException: no such column: IDMENUS (code 1): , while compiling: SELECT * FROM PLATS WHERE IDMENUS=
Please Help me.
First option is that you should raise the value of your database version in the Manifest.xml:
<meta-data android:name="VERSION" android:value="2" />
That should be done every time you change something of the classes that you save in your database.
The other option is that you just pick the wrong column name.
I think you should try: "ID_MENUS" as column name and not use the NamingHelper. Because i've seen that kind of names more then IDMENUS ("example).

Why do I get syntax error when creating a view with column names?

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.

sqlite query runtime error

I was working with sqlite but I end up with this error.I'm not getting what is error here.
Below is my logcat.
android.database.sqlite.SQLiteException: near "/": syntax error: , while compiling:
SELECT start,end FROM crop_list WHERE name =/sdcard/Shri Ramachandra kripalu bhajamana.mp3
I think your problem is you forget to add the quotes marks (' ') like:
SELECT start,end FROM crop_list WHERE name ='/sdcard/Shri Ramachandra kripalu bhajamana.mp3'.
why do you not use class helper and Helper.dabase.query(.....) <- it is faster ;) around 2 segons faster that helper.dabase.rawquery ;)
SQLiteOpenHelper | Android Developers <-- best practice

Categories

Resources