On Android, is there any way that I can execute a raw android.database.sqlite
query that starts with a WITH clause such as: WITH one(x) AS (SELECT 1) SELECT x FROM one;
?
The following fragment gives me a syntax error message (in my main activity code):
AlertDialog.Builder b = new AlertDialog.Builder(this);
AlertDialog ad = b.create();
SQLiteDatabase db;
Cursor c;
try {
db = this.openOrCreateDatabase("test.db", 0, null);
} catch (Exception e) {
ad.setMessage("Could not open database: " + e.toString());
ad.show();
return;
}
try {
c = db.rawQuery("WITH one(x) AS (SELECT 1) SELECT x FROM one;", new String[0]);
} catch (Exception e) {
ad.setMessage("Could not execute query: " + e.toString());
ad.show();
return;
}
if (c == null)
ad.setMessage("Got null query result");
else
ad.setMessage("Got valid query result");
ad.show();
It works if I replace the db.rawQuery
statement with:
c = db.rawQuery("SELECT 1;", new String[0]);
UPDATE 1 (edited): The same WITH one(x) AS (SELECT 1) SELECT x FROM one;
statement works for me in the following:
- sqlite3 CLI
- within a Web SQL transaction on
Android andiOS (iOS 9.2, not 8.0) - in the iOS version of https://github.com/litehelpers/Cordova-sqlite-storage (iOS 9.2, not 8.0).