以下是我的代码:
try{
String userid = SystemPlatformFactory.getPlatform().getSystem().getUserID();
String[] args = new String[]{userid};
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("DELETE sa FROM stubout_account sa INNER JOIN stubout s ON sa.parentid = s.objid INNER JOIN area r ON s.areaid = r.objid WHERE r.assigneeid = ?",args);
db.close();
}catch(Exception e){
e.printStackTrace();
ERROR = "Database Error: " + e.toString();
}
执行上述代码会产生此错误:
W/System.err(31732): android.database.sqlite.SQLiteException: near "sa": syntax error (code 1): , while compiling: DELETE sa FROM stubout_account sa INNER JOIN stubout s ON sa.parentid = s.objid INNER JOIN area r ON s.areaid = r.objid WHERE r.assigneeid = ?
W/System.err(31732): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
W/System.err(31732): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1093)
W/System.err(31732): at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:670)
W/System.err(31732): at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
W/System.err(31732): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59)
W/System.err(31732): at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
W/System.err(31732): at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1798)
W/System.err(31732): at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1779)
W/System.err(31732): at com.rameses.waterworks.database.AndroidDatabase.clearStuboutAccount(AndroidDatabase.java:889)
W/System.err(31732): at com.rameses.waterworks.page.Download.clearReadingGroups(Download.java:372)
W/System.err(31732): at com.rameses.waterworks.page.Download.access$000(Download.java:48)
W/System.err(31732): at com.rameses.waterworks.page.Download$2.handle(Download.java:146)
W/System.err(31732): at com.rameses.waterworks.page.Download$2.handle(Download.java:97)
错误的原因是什么?如何解决这个问题?
答案 0 :(得分:-1)
db.execSQL("DELETE sa.* FROM stubout_account sa INNER JOIN stubout s ON sa.parentid = s.objid INNER JOIN area r ON s.areaid = r.objid WHERE r.assigneeid = ?",args);