jeudi 16 juillet 2015

No Such table for View Sql

i written follwoing function to query database.In my first query i am creating view "allsourcecopy2" as resultant of query.When i am trying to query "allsourcecopy2" it gives error ""No Such Table:allsourcecopy2"

 public void table_result(String dbpath)
    {
        SQLiteDatabase db1 = this.getWritableDatabase();
        db1.openDatabase(dbpath, null, SQLiteDatabase.OPEN_READWRITE);
        String countQuery1 =" CREATE VIEW allsourcecopy2 AS "+
                "SELECT * FROM allsourcecopy GROUP BY id,status,amount,name,date HAVING COUNT(*) > 1 "+

                "  UNION "+

                " SELECT * FROM allsourcecopy  allsourcecopy WHERE id IN"+
                "(SELECT id FROM allsourcecopy GROUP BY id HAVING COUNT(DISTINCT name) > 1 AND COUNT(DISTINCT date) > 1)"+

                " UNION "+

                " SELECT * FROM allsourcecopy  allsourcecopy WHERE status=1 AND id IN"+
                "(SELECT id FROM allsourcecopy GROUP BY id HAVING COUNT(id) >= 2);";



        Cursor cursor11 = db1.rawQuery(countQuery1, null);

        String countQuery12 =" SELECT * FROM allsourcecopy2"+

                " UNION "+

                "SELECT * FROM allsourcecopy WHERE id NOT IN (SELECT id FROM allsourcecopy2);";
        Cursor cursor12 = db1.rawQuery(countQuery12, null);
    }

Aucun commentaire:

Enregistrer un commentaire