* PS 这个查询给出了 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) 没有这样的表: 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:线程退出未捕获的异常(组= 0x40a71930)10-17 06:38:01.574:E / AndroidRuntime(4107):致命异常:主要10-17 06:38: 01.574: E/AndroidRuntime(4107): android.database.sqlite.SQLiteException: no such table: qt_um_stock_items_qty (code 1): , while compile: 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 来自 qt_um_stock_items_qty WHERE STOCK_CENTER_ID = ? AND STOCK_ITEM_ID=? 10-17 06:38:01.574: E/AndroidRuntime(4107): 在安卓。