SQL 错误 ORA-00904:标识符无效

Posted

技术标签:

【中文标题】SQL 错误 ORA-00904:标识符无效【英文标题】:SQL Error ORA-00904: invalid identifier 【发布时间】:2016-08-23 16:41:39 【问题描述】:

我正在尝试在 Oracle SQL 开发人员中运行此 sql,但我收到了

的错误
ORA-00904: "I"."SZ": invalid identifier
00904. 00000 -  "%s: invalid identifier"
*Cause:    
*Action:
Error at Line: 13 Column: 122

我不确定是什么问题。我的一个朋友能够毫无问题地运行他发给我的这个 sql。我也在使用虚拟机。

这是我的 SQL:

 SELECT 
                              oi.ID              AS ID, 
                              r.MARKET_CENTER_ID AS MARKET_CENTER_ID, 
                              SUBSTR(('0000' || r.MARKET_CENTER_ID),-4,4) AS MARKET_CENTER_NUMBER, 
                              r.ID               AS ROUTE_ID, 
                              r.NBR           AS ROUTE_NUMBER, 
                              oh.WORK_ORDER_DATE AS ORDER_DATE, 
                              c.NBR           AS CID, 
                              c.NAME             AS CUSTOMER_NAME, 
                              c.GARMENT_MARK     AS GID, 
                              oi.WEARER_NUMBER   AS WEARER_NUMBER, 
                              TRIM(oi.WEARER_FIRST_NAME || ' ' || oi.WEARER_LAST_NAME) AS WEARER_NAME, 
                              (CASE WHEN (i.ID) IS NULL THEN oi.ITEM_NUMBER ELSE i.CATEGORY || i.STYLE || i.COLOR || i.SZ END) AS ITEM_NUMBER, 
                              oh.INVENTORY_CODE             AS INVENTORY_CODE, 
                              NVL(oi.RTS_QTY,0)          AS EXPECTED_RTS, 
                              NVL(oi.RTS_RTS_QTY,0)      AS RTS_QTY, 
                              NVL(oi.RTS_RUIN_QTY,0)     AS RTS_RUIN, 
                              NVL(oi.RTS_ABUSE_QTY,0)    AS RTS_ABUSE, 
                              NVL(oi.RTS_RTW_QTY,0)      AS RTW, 
                              NVL(oi.RTS_LOSS_QTY,0)     AS RTS_LOSS, 
                              NVL(oi.RUIN_QTY,0)         AS RUIN, 
                              NVL(oi.LOSS_QTY,0)         AS LOSS, 
                              NVL(oi.ADJ_QTY,0)          AS ADJ, 
                              (CASE WHEN EC.ID IS NULL OR c.EC_STATUS <> 'A' THEN 0 ELSE 1 END)       AS EASY_CARE_LINE, 
                              (CASE WHEN oi.HH_MODULE = 'ExcessMerchandise' THEN 1 ELSE 0 END) AS EXCESS_MERCH, 
                              ic.INV_DESC AS INV_DESC  
                            FROM route r 
                              INNER JOIN customer c 
                                ON c.ROUTE_ID = r.ID 
                              INNER JOIN order_header oh 
                                ON oh.CUSTOMER_ID = c.ID 
                              INNER JOIN order_item oi 
                                ON oi.ORDER_HEADER_ID = oh.ID 
                              LEFT JOIN inventory_code ic 
                                ON ic.INV_CODE = oh.INVENTORY_CODE 
                              LEFT JOIN customer_item ci 
                                ON ci.ID = oi.CUSTOMER_ITEM_ID 
                                   AND NOT oi.EXCHANGE_ITEM_ID IS NULL 
                              LEFT JOIN item i 
                                ON i.ID = ci.ITEM_ID 
                              LEFT JOIN customer_item ci2 
                                ON ci2.ID = oi.CUSTOMER_ITEM_ID 
                              LEFT JOIN item i2 
                                ON i2.ID = ci2.ITEM_ID 
                              LEFT JOIN ECARE_ITEMS EC 
                                ON EC.CUSTOMER_ID = c.ID 
                                  AND EC.ITEM_CATEGORY = i2.CATEGORY 
                                  AND EC.ITEM_STYLE = i2.STYLE 
                                  AND EC.ITEM_COLOR = i2.COLOR 
                                  AND EC.IE_FLAG = 'Y' 
                                  WHERE 

                             (CASE WHEN EC.ID IS NULL OR c.EC_STATUS <> 'A' THEN 0 ELSE 1 END) = 1
                            AND oh.INVENTORY_CODE != '3G'
                                AND oh.STATUS_ID = 3;

【问题讨论】:

item上可能没有名为SZ的列 运行desc item并上传输出 数据库中的“你”和“你的同事”是不同的用户(模式)吗?那么您同事架构中的 item 表可能有一个列 SZ 并且您的同一个表的副本没有它,或者它具有不同的名称。另外,靠近代码底部的“禁用按钮”是什么? (“按钮”也拼错了)。这不会导致您报告的错误,但它看起来完全不合适。 @mathguy 我们指向同一个模式/数据库。我仔细检查了他,这对他有用。那个按钮拼写错误是我忘记在这里删除的评论。 【参考方案1】:

脚本中的一个源列名称不正确。

【讨论】:

以上是关于SQL 错误 ORA-00904:标识符无效的主要内容,如果未能解决你的问题,请参考以下文章

SQL 错误 ORA-00904:标识符无效

SQL 错误:ORA-00904:创建表期间标识符无效

SQL 错误:ORA-00904:“CNPPARMID”:标识符无效

SQL 错误:ORA-00904: : 第 4 行中的标识符无效

错误:PL/SQL:ORA-00904::标识符无效

SQL 错误 [904] [42000]:ORA-00904:“SPAREBOX”:无效标识符 [重复]