mardi 21 avril 2015

SQLite error column (that exists) does not exist when compiling CREATE VIEW

I'm trying to create a view but for some reason it's giving me a column does not exist error. This isn't the first view I've made and all the others are working, the tables are there, columns and all ( I checked with DBBrowser and everything but this one VIEW is not working ).

I've checked my whitespaces, it's all in order but something is going wrong and I've been pulling my hair out trying to figure out what. Can someone shed some light on this?

LogCat

 Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.jc.pseudocc/com.example.jc.pseudocc.AccountManager}: android.database.sqlite.SQLiteException: no such column: Companies.CompanyID (code 1): , while compiling: CREATE VIEW ViewCompanies AS SELECT Companies.CompanyID AS _id, Payments.GroupID, Payments.PaymentDue, Payments.DateDue FROM Payments JOIN Accounts ON Payments.GroupID = Accounts.AccountID

Tables

COMPANY

db.execSQL("CREATE TABLE " + COMPANY + " (" + colCompID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
            colCompClass + " TEXT)");

PAYMENTS

db.execSQL("CREATE TABLE " + PAYMENTS + " (" + colPayID + " INTEGER PRIMARY KEY , " +
            colGroupID + " INTEGER NOT NULL, " +
            colPayBal + " TEXT, " +
            colInterest + " TEXT, " +
            colPayDue + " TEXT, " +
            colDateDue + " TEXT, " +
            colPayDate + " TEXT, " +
            "FOREIGN KEY (" + colGroupID + ") REFERENCES " + ACCOUNTS + " (" + colID + ") ON DELETE CASCADE);");

VIEW

db.execSQL("CREATE VIEW " + viewComps +
            " AS SELECT " + COMPANY + "." + colCompID + " AS _id," +
            " " + COMPANY + "." + colCompClass + "," +
            " " + PAYMENTS + "." + colGroupID + "," +
            " " + PAYMENTS + "." + colPayDue + "," +
            " " + PAYMENTS + "." + colDateDue + "" +
            " FROM " + PAYMENTS +
            " JOIN " + ACCOUNTS + " ON " + PAYMENTS + "." + colGroupID + " = " + ACCOUNTS + "." + colID );

Aucun commentaire:

Enregistrer un commentaire