lundi 26 janvier 2015

Android thinks my sqlite table is a column

One of the methods of my app intends to return a Cursor with the resultset of a Inner Join query from my db. The operation should get two columns from one table (Table Gastos) and one column from the other table (RUBRICAS) inner join then and returning the SUM VALOR for each group (GROUP BY RUBRICAS.NOME).


Something like



NOME Valor
TELEFONE R$ 50,00
ALUGUEL r$ 45,00


.



public Cursor getCursorGastos (){
String query ="SELECT GASTOS._id, SUM(GASTOS.VALOR), RUBRICAS.NOME FROM GASTOS INNER JOIN RUBRICAS ON GASTOS.ID_RUBRICA = RUBRICAS._id GROUP BY NOME";


SQLiteDatabase db = this.getWritableDatabase();
db.beginTransaction();
Cursor cursor = db.rawQuery(query, null);
db.endTransaction();
db.close();

return cursor;

}


That is the problem, androids keeps giving me this error:



01-26 22:51:22.100: E/AndroidRuntime(2268): FATAL EXCEPTION: main
01-26 22:51:22.100: E/AndroidRuntime(2268): Process: com.example.joolus.orcamento, PID: 2268
01-26 22:51:22.100: E/AndroidRuntime(2268): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.joolus.orcamento/com.example.joolus.orcamento.Gastos}: java.lang.IllegalArgumentException: column 'RUBRICAS' does not exist


Take a look that it is thinking that "RUBRICAS" is a column, while it is actually a table, and I can't figure out how to fix it.


Thank you


Aucun commentaire:

Enregistrer un commentaire