I've a problem on this query:
WITH RECURSIVE dates(d)
AS (VALUES('2014-03-01')
UNION ALL
SELECT date(d, '+1 day')
FROM dates
WHERE d < '2014-03-31')
SELECT d AS date
If I execute this query on dedicated SqLite's application for windows, the query works fine.
If I execute this query on my android app, I receive this message as log:
/com.robertot.timereport E/SQLiteLog﹕ (1) near "WITH": syntax error
/com.robertot.timereport W/System.err﹕ java.sql.SQLException: Could not perform raw query for WITH RECURSIVE dates(d) AS (VALUES('2014-04-28') UNION ALL SELECT date(d, '+1 day') FROM dates WHERE d < '2014-06-01') SELECT d AS date
I don't understand why...
Anyway, this is my java code:
GenericRawResults<String[]> rawResults;
List<String[]> results = null;
DbHelperJob findjob = new DbHelperJob(getActivity());
try
{
rawResults = findjob.getJobDao().queryRaw("WITH RECURSIVE dates(d) " +
"AS (VALUES('" + firstWeek + "') " +
"UNION ALL " +
"SELECT date(d, '+1 day') " +
"FROM dates " +
"WHERE d < '" + lastWeek + "') " +
"SELECT d AS date"
results = rawResults.getResults();
findjob.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
Thanks!! :)