0
我試圖創建一個視圖,但由於某種原因,它給了我一個列不存在的錯誤。這不是我所做的第一個視圖,所有其他人都在工作,表格在那裏,列和所有(我用DBBrowser檢查,除了這一個VIEW不工作)。編譯CREATE VIEW時不存在SQLite錯誤列(存在)
我檢查了我的空白區,這一切都是爲了順序,但有些事情出錯了,我一直在拉我的頭髮,試圖找出什麼。有人可以對此有所瞭解嗎?
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
表
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);
應該'」 FROM 「+付款+'是'」 FROM 「+付款+」 ,「+ COMPANY +'? – njzk2
我現在在哭,那個時候我不再編碼,因爲我再也不用編寫怪物來睡覺了。謝謝你,我有一種感覺,我錯過了一些東西。將它發佈爲答案,以便我們可以在SO中完成我的第一個愚蠢問題。 – Cytus