【问题标题】:Derby "&" is not working德比“&”不工作
【发布时间】:2016-02-24 09:28:08
【问题描述】:
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)

我在互联网上搜索了很多,但我仍然没有得到解决方案。

【问题讨论】:

    标签: derby


    【解决方案1】:

    我猜你想使用&amp; 连接字符串。

    对于连接,您必须使用||

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

    【讨论】:

    • 完成上述更改后,我在同一查询中遇到新错误。
    • java.sql.SQLSyntaxErrorException: 列 'APP.BCA_CUSTOMSELECT.QTY' 要么不在 FROM 列表中的任何表中,要么出现在连接规范中,并且超出连接规范的范围或出现在一个 HAVING 子句并且不在 GROUP BY 列表中。如果这是 CREATE 或 ALTER TABLE 语句,则“APP.BCA_CUSTOMSELECT.QTY”不是目标表中的列。在 org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source) at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
    • 您的查询中的APP 是什么?数据库架构还是什么?
    猜你喜欢
    • 1970-01-01
    • 2016-06-10
    • 2016-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-21
    • 1970-01-01
    相关资源
    最近更新 更多