2016-02-24 42 views
1
Select distinct APP.bca_cart.InventoryCode,APP.bca_cart.InventoryID,APP.bca_cart.CartID,APP.bca_cart.InvoiceID,APP.bca_cart.UnitPrice,APP.bca_cart.DateAdded,APP.bca_cart.CustomSku,APP.bca_cart.InventoryCode & '-' & APP.bca_cart.CustomSku AS fullsku,APP.bca_cart.Qty AS O_QTY,APP.storage_clientvendor.FirstName,APP.storage_clientvendor.LastName,APP.storage_clientvendor.Name FROM ((APP.bca_iteminventory INNER JOIN (APP.bca_cart INNER JOIN APP.bca_invoice ON APP.bca_cart.InvoiceID = APP.bca_invoice.InvoiceID) ON APP.bca_iteminventory.InventoryID = APP.bca_cart.InventoryID)INNER JOIN APP.storage_clientvendor ON APP.bca_invoice.ClientVendorID =APP.storage_clientvendor.ClientVendorID) Where APP.bca_iteminventory.StoreTypeID <= 0 AND APP.bca_iteminventory.ItemTypeID NOT IN (5,4,6) AND APP.bca_iteminventory.companyId =18 ORDER BY APP. storage_clientvendor.LastName ASC 

我正在跟蹤Stacktrace。請幫我解決這個錯誤。德比「&」不起作用

SEVERE: null 
java.sql.SQLSyntaxErrorException: Syntax error: Encountered "&" at line 1, column 145. 
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source) 
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) 
at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source) 
at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source) 
at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source) 
at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source) 
at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source) 
at org.apache.derby.impl.jdbc.EmbedStatement.executeQuery(Unknown Source) 
at com.bzcomposer.global.tables.tblItemLoader.getBackOrderItemListByCustomer(tblItemLoader.java:8488) 
at com.bzcomposer.items.ItemListPanel$BackOrderItemModel.setTableData(ItemListPanel.java:4424) 
at com.bzcomposer.items.ItemListPanel$BackOrderItemModel.<init>(ItemListPanel.java:4407) 
at com.bzcomposer.items.ItemListPanel.<init>(ItemListPanel.java:140) 
at com.bzcomposer.modules.internalPanel.SalesPanels.<init>(SalesPanels.java:90) 
at com.bzcomposer.modules.internalPanel.InternalPanelsControl.init_internalPanel1(InternalPanelsControl.java:162) 
at com.bzcomposer.modules.MainFrame2.init_internalframe1(MainFrame2.java:1104) 
at com.bzcomposer.modules.MainFrame2.invokeInit(MainFrame2.java:816) 
at com.bzcomposer.modules.MainPanel$1.run(MainPanel.java:393) 
Caused by: java.sql.SQLException: Syntax error: Encountered "&" at line 1, column 145. 
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source) 
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source) 
... 17 more 
Caused by: ERROR 42X01: Syntax error: Encountered "&" at line 1, column 145. 
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source) 
at org.apache.derby.impl.sql.compile.ParserImpl.parseStatement(Unknown Source) 

我在互聯網上搜索很多,但我仍然沒有得到它的解決方案。

回答

2

我想你想通過使用&來協調字符串。

對於concatination你必須使用||

APP.bca_cart.InventoryCode || '-' || APP.bca_cart.CustomSku 
+0

與我在同一個查詢中獲得新的錯誤上述變化完成後。 –

+0

java.sql.SQLSyntaxErrorException:列「APP.BCA_CUSTOMSELECT.QTY」不在FROM列表中的任何表中,或者出現在聯接規範中,並且超出了聯接規範的範圍或出現在HAVING子句中,並且不在GROUP BY列表。如果這是一個CREATE或ALTER TABLE語句,那麼'APP.BCA_CUSTOMSELECT.QTY'不是目標表中的一列。 at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) –

+0

查詢中的「APP」是什麼?數據庫Schema還是什麼? – Jens