I’ve been keen to learn about triggers in Android and SQLite. I found a great tutorial at:
http://android-pro.blogspot.com/2010/10/using-sqlite-database-with-android.html
However, having imported their project into Eclipse and tried running it, I get the error:
android.database.SQLiteException: no such column EmployeeName while compiling: SELECT _id,EmployeeName, Age, DeptName FROM ViewEmps WHERE DeptName=?
This occurs when trying to view information from the database after selecting an items foreign key. e.g. add person to dept IT. Go to view screen, select IT and the error occurs.
The author of the tutorial has tried to solve the issue by saying increase the database version but this doesn’t seem to have worked for anyone. The part of the code which causes the error seems to be this:
db.execSQL("CREATE VIEW "+viewEmps+
" AS SELECT "+employeeTable+"."+colID+" AS _id,"+
" "+employeeTable+"."+colName+","+
" "+employeeTable+"."+colAge+","+
" "+deptTable+"."+colDeptName+""+
" FROM "+employeeTable+" JOIN "+deptTable+
" ON "+employeeTable+"."+colDept+" ="+deptTable+"."+colDeptID
);
I have tried chopping and changing bits and tried to debug myself but have gotten nowhere with it. If anyone has any ideas then it would be greatly appreciated. If anyone could download the code from the website above and try it to see their results would be really helpful as it seems to only be happening to a few people. If any more information is required then let me know and I will try to help.
EDIT: if anyone wants to download the source then I have also uploaded it to MediaFire as some people have been having problems with the other mirror. Grab it at: http://www.mediafire.com/?2ya4jsbcuiyq3m5
Try to change it to:
Just added
to columns in select.