【问题标题】:Invalid identifier when I query in my table在我的表中查询时标识符无效
【发布时间】:2017-03-29 09:37:03
【问题描述】:

在我的表ALI_LEASE_IN,我有一个DEF14字段,(对不起红框,选择DEF16),你可以在我的快照中看到。

但是当我执行查询sql时:

select b.equip_name a2,b.model b3,b.def2 c4,b.def3 d5,
  ALI_LEASE_IN.DEF14 as e6,
  '' f7,
  To_char(b.pre_rent) h9,
  b.start_date k10,
  sup.name j11,
  org.name l12, 
  b.memo o13,
  h.bill_date bdate,
  h.pk_group
from ali_lease_in_b b,ali_lease_in h,bd_supplier sup,org_itemorg org 
where b.pk_lease_in=h.pk_lease_in 
  and h.pk_supplier=sup.pk_supplier 
  and b.pk_org=org.pk_itemorg

但我在下面收到此错误:

[SQL]select b.equip_name a2,b.model b3,b.def2 c4,b.def3 d5,  
ALI_LEASE_IN.DEF14 as e6,  
'' f7,  
To_char(b.pre_rent) h9,b.start_date k10,sup.name j11,org.name l12, b.memo o13,h.bill_date bdate,h.pk_group  
from ali_lease_in_b b,ali_lease_in h,bd_supplier sup,org_itemorg org   
where b.pk_lease_in=h.pk_lease_in   
and h.pk_supplier=sup.pk_supplier   
and b.pk_org=org.pk_itemorg  
--and h.pk_org in (parameter('param3'))  
                   --     and substr(h.bill_date,1,10) >= parameter('param1')  
                    --    and substr(h.bill_date,1,10) <= parameter('param2')  
[Err] ORA-00904: "ALI_LEASE_IN"."DEF14": invalid identifier

我不知道为什么,我的快照显示 DEF14 存在于我的表中。

我的环境是:

数据库是Oracle, 可视化软件是navicat。

【问题讨论】:

  • 尝试用h.DEF14替换您选择中的ALI_LEASE_IN.DEF14,该字段是ALI_LEASE_IN表的一部分,在您的FROM 子句中别名为h。

标签: sql oracle navicat


【解决方案1】:

我看到了你的代码:

from ali_lease_in_b b,ali_lease_in h,bd_supplier sup,org_itemorg org 

这一行你得到了表ali_lease_in一个别名h

所以你应该使用别名,换行:

ALI_LEASE_IN.DEF14 as e6,

到:

h.DEF14 as e6

【讨论】:

    【解决方案2】:

    当您为 DEF14 提供表别名时,您已经为 DEF14 引用了 ALI_LEASE_IN。将该列更改为 h.DEF14 AS e6。

    SELECT b.equip_name a2,
       b.model b3,
       b.def2 c4,
       b.def3 d5,
       h.DEF14 AS e6,
       '' f7,
       TO_CHAR (b.pre_rent) h9,
       b.start_date k10,
       sup.name j11,
       org.name l12,
       b.memo o13,
       h.bill_date bdate,
       h.pk_group
    FROM   ali_lease_in_b b,
       ali_lease_in h,
       bd_supplier sup,
       org_itemorg org
    WHERE      b.pk_lease_in = h.pk_lease_in
       AND h.pk_supplier = sup.pk_supplier
       AND b.pk_org = org.pk_itemorg
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-02
      • 1970-01-01
      • 1970-01-01
      • 2023-01-12
      相关资源
      最近更新 更多