* PS這個查詢是給SQLite的異常*錯誤執行SQLite的查詢
Cursor cur= db.rawQuery("SELECT " + Constants.Qt_um_stock_items_qty_BAL_DATE + " AS_ON_DT, " + " (IFNULL (" + Constants.Qt_um_stock_items_qty_IN_QTY +", 0)-IFNULL ("
+Constants.Qt_um_stock_items_qty_OUT_QTY +", 0)) AS CL_QTY,"+ "(SELECT " + Constants.Stock_ItemsCODE + " || '-' || "
+ Constants.Stock_ItemsNAME + " FROM " + Constants.Qm_Stock_Items_TABLE + " WHERE " + Constants.Stock_ItemsID + " = "
+ Constants.Qt_um_stock_items_qty_STOCK_ITEM_ID+") AS ITEM," + "(SELECT " + Constants.UnitCODE + "|| '-' ||"
+ Constants.UnitNAME + " FROM " + Constants. Qm_Unit_TABLE + " WHERE " + Constants.UnitID + " = "
+ Constants.Qt_um_stock_items_qty_BASE_UNIT_ID+") AS UNIT FROM " + Constants.Qt_um_stock_items_qty_table +" WHERE "
+ Constants. Qt_um_stock_items_qty_STOCK_CENTRE_ID+"=?" + " AND " + Constants. Qt_um_stock_items_qty_STOCK_ITEM_ID
+ " IN " + "=?",new String[] {StockCenterId, StockItemId});
登錄貓
10-17 06:02:50.042: E/SQLiteLog(3608): (1) near "=": syntax error
10-17 06:02:50.054: D/AndroidRuntime(3608): Shutting down VM
10-17 06:02:50.054: W/dalvikvm(3608): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
10-17 06:02:50.114: E/AndroidRuntime(3608): FATAL EXCEPTION: main
10-17 06:02:50.114: E/AndroidRuntime(3608): android.database.sqlite.SQLiteException: near "=": syntax error (code 1): , while compiling: SELECT BAL_DATE AS_ON_DT, (IFNULL (IN_QTY, 0)-IFNULL (OUT_QTY, 0)) AS CL_QTY,(SELECT CODE || '-' || NAME FROM qm_um_stock_items WHERE ID = STOCK_ITEM_ID) AS ITEM,(SELECT CODE|| '-' ||NAME FROM qm_um_unit WHERE ID = BASE_UNIT_ID) AS UNIT FROM Qt_um_stock_items_qty WHERE STOCK_CENTER_ID =? AND STOCK_ITEM_ID IN (=?)
10-17 06:02:50.114: E/AndroidRuntime(3608): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
10-17 06:02:50.114: E/AndroidRuntime(3608): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882)
10-17 06:02:50.114: E/AndroidRuntime(3608): at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:493)
10-17 06:02:50.114: E/AndroidRuntime(3608): at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
10-17 06:02:50.114: E/AndroidRuntime(3608): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
10-17 06:02:50.114: E/AndroidRuntime(3608): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
10-17 06:02:50.114: E/AndroidRuntime(3608): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
10-17 06:02:50.114: E/AndroidRuntime(3608): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1314)
10-17 06:02:50.114: E/AndroidRuntime(3608): at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1253)
10-17 06:02:50.114: E/AndroidRuntime(3608): at com.manacle.umma.activity.HeaderDb.getStockbal(HeaderDb.java:3901)
10-17 06:02:50.114: E/AndroidRuntime(3608): at com.manacle.umma.activity.StockBalrep$4.onClick(StockBalrep.java:185)
10-17 06:02:50.114: E/AndroidRuntime(3608): at android.view.View.performClick(View.java:4204)
10-17 06:02:50.114: E/AndroidRuntime(3608): at android.view.View$PerformClick.run(View.java:17355)
10-17 06:02:50.114: E/AndroidRuntime(3608): at android.os.Handler.handleCallback(Handler.java:725)
10-17 06:02:50.114: E/AndroidRuntime(3608): at android.os.Handler.dispatchMessage(Handler.java:92)
10-17 06:02:50.114: E/AndroidRuntime(3608): at android.os.Looper.loop(Looper.java:137)
10-17 06:02:50.114: E/AndroidRuntime(3608): at android.app.ActivityThread.main(ActivityThread.java:5041)
10-17 06:02:50.114: E/AndroidRuntime(3608): at java.lang.reflect.Method.invokeNative(Native Method)
10-17 06:02:50.114: E/AndroidRuntime(3608): at java.lang.reflect.Method.invoke(Method.java:511)
10-17 06:02:50.114: E/AndroidRuntime(3608): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
10-17 06:02:50.114: E/AndroidRuntime(3608): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
10-17 06:02:50.114: E/AndroidRuntime(3608): at dalvik.system.NativeStart.main(Native Method)
新日誌貓:這是沒有表現出這樣的表qt_um_stock_items_qty但我在我的數據庫中有這張表,我可以使用我的數據庫瀏覽器訪問它
10-17 06:38:01.523 E/SQLiteLog(4107):(1)no such table:qt_um_stock_items_qty 10-17 06:38:01.523:D/AndroidRuntime(4107):關閉VM 10-17 06:38:01.523:W/dalvikvm(4107):threadid = 1:線程以未捕獲的異常退出(group = 0x40a71930) 10-17 06:38:01.574:E/AndroidRuntime(4107):致命例外:main 10 -17 06:38:01.574:E/AndroidRuntime(4107):android.database.sqlite.SQLiteException:no such table:qt_um_stock_items_qty(code 1):,while compiling:SELECT BAL_DATE AS ON_DT,(IFNULL(IN_QTY,0) - IFNULL(OUT_QTY,0))AS CL_QTY,(SELECT CODE || ' - '||名稱從qm_um_stock_items WHERE ID = STOCK_ITEM_ID)作爲項目,(選擇代碼||' - '||名稱從qm_um_unit WHERE ID = BASE_UNIT_ID)作爲單位從qt_um_stock_items_qty WHERE STOCK_CENTER_ID =? AND STOCK_ITEM_ID =? E/AndroidRuntime(4107):at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) 10-17 06:38:01.574:E/AndroidRuntime(4107):at android .database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882) 10-17 06:38:01.574:E/AndroidRuntime(4107):at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:493) 10-17 06:38:01.574:E/AndroidRuntime(4107):at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588) 10-17 06:38:01.574:E/AndroidRuntime(4107):在android.database.sqlite.SQLiteProgram。(SQLiteProgram.java:58) 10-17 06:38:01.574:E/AndroidRuntime(4107):at android.database.sqlite.SQLiteQuery。(SQLiteQuery.java:37) 10-17 06:38:01.574:E/AndroidRuntime(4107):at droid.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44) 10-17 06:38:01.574:E/AndroidRuntime(4107):at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1314) E/AndroidRuntime(4107):at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1253) 10-17 06:38:01.574:E/AndroidRuntime(4107) :at com.manacle.umma.activity.HeaderDb.getStockbal(HeaderDb.java:3901) 10-17 06:38:01.574:E/AndroidRuntime(4107):at com.manacle.umma.activity.StockBalrep $ 4.onClick (StockBalrep.java:185) 10-17 06:38:01.574:E/AndroidRuntime(4107):at android.view.View.performClick(View.java:4204) 10-17 06:38:01.574:E/AndroidRuntime(4107):at android.view.View $ PerformClick.run(View.java:17355) 10-17 06:38:01.574:E/AndroidRuntime(4107):at android.os.Handler.handleCallback(Handler.java:725) 10-17 06:38:01.574:E/AndroidRuntime(4107):at android.os。 Handler.dispatchMessage(Handler.java:92) 10-17 06:38:01.574:E/AndroidRuntime(4107):at android.os.Looper.loop(Looper.java:137) 10-17 06:38: 01.574:E/AndroidRuntime(4107):at android.app.ActivityThread.main(ActivityThread.java:5041) 10-17 06:38:01.574:E/AndroidRuntime(4107):at java.lang.reflect.Method。 invokeNative(Native Method) 10-17 06:38:01.574:E/AndroidRuntime(4107):at java.lang.reflect.Method.invoke(Method.java:511) 10-17 06:38:01.574:E/AndroidRuntime(4107):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:793) 10-17 06:38:01.574:E/AndroidRuntime(4107):at com.android.in ternal.os.ZygoteInit.main(ZygoteInit。Java的:560) 6月10日至17日:38:01.574:E/AndroidRuntime(4107):在dalvik.system.NativeStart.main(本機方法)
請發表完整例外 – laalto
你可以發佈此查詢字符串嗎?所以它更容易閱讀 – waqaslam
昨天你有另一個異常,是查詢仍然是一樣的? – laalto