【问题标题】:"ORA-00920: invalid relational operator" Error“ORA-00920:无效的关系运算符”错误
【发布时间】:2020-02-07 04:22:25
【问题描述】:
select 
    ic.item_name,
    lh.locn_brcd from_locn,
    lh2.locn_brcd to_locn,
    wl.from_container,
    wl.to_container,
    wl.units,
    wl.prev_from_container_status prev_from_lpn_status, 
    wl.curr_from_container_status curr_from_lpn_status,
    wl.prev_to_container_status prev_to_lpn_status,
    wl.curr_to_container_status curr_to_lpn_status,
    wl.work_batch_number,
    wl.transaction_name,
    wl.action,
    wl.work_id,
    wl.date_updated,
    wl.source_updated,
    wl.tote_number,
    wl.chute     
from m_work_log wl     
    LEFT join item_cbo ic on wl.item_id=ic.item_id
    left join locn_hdr lh on wl.from_location_id = lh.locn_id
    left join locn_hdr lh2 on wl.to_location_id = lh2.locn_id    
where wl.action in (:action)    
    and trunc(wl.date_updated) between :start_date and :end_date
    and (ic.item_name in (:list) OR  
         wl.source_updated = :username OR 
         wl.to_container in (:LPNList) OR 
         (:list is null and :username is null and :LPNList is null)
        )
    order by date_updated desc

大家好,

当我通过 Oracle SQL Developer 运行此代码并将两个项目添加到 :list 参数和两个项目到 :action 参数时,它工作正常。但是当我通过 SSRS(报告生成器)运行它时,它无法运行并且我得到一个“ORA-00920:无效的关系运算符”。我是 SQL 新手,我不确定我在这里做错了什么。任何帮助是极大的赞赏。谢谢!

【问题讨论】:

    标签: sql oracle reporting-services


    【解决方案1】:

    有两种方法可以做到这一点:

    1. 多值参数: 首先,您必须使用 Oracle 提供程序,多值参数不适用于 ODBC 和 OLEDB 连接 (reference)。 这是一个外部链接,详细解释here

    2. 使用表达式作为查询,将整个内容像这样="query_here"

    ="select "
    + "    ic.item_name,"
    + "    lh.locn_brcd from_locn,"
    + "    lh2.locn_brcd to_locn,"
    + "    wl.from_container,"
    + "    wl.to_container,"
    + "    wl.units,"
    + "    wl.prev_from_container_status prev_from_lpn_status,"
    + "    wl.curr_from_container_status curr_from_lpn_status,"
    + "    wl.prev_to_container_status prev_to_lpn_status,"
    + "    wl.curr_to_container_status curr_to_lpn_status,"
    + "    wl.work_batch_number,"
    + "    wl.transaction_name,"
    + "    wl.action,"
    + "    wl.work_id,"
    + "    wl.date_updated,"
    + "    wl.source_updated,"
    + "    wl.tote_number,"
    + "    wl.chute"
    + "from m_work_log wl"
    + "    LEFT join item_cbo ic on wl.item_id=ic.item_id"
    + "    left join locn_hdr lh on wl.from_location_id = lh.locn_id"
    + "    left join locn_hdr lh2 on wl.to_location_id = lh2.locn_id"
    + "where wl.action in (:action)"
    + "    and trunc(wl.date_updated) between :start_date and :end_date"
    + "    and (ic.item_name in ('" + Join(Parameters!list.Value , "', '")" + ') OR"
    + "         wl.source_updated = :username OR"
    + "         wl.to_container in ('" + Join(Parameters!LPNList.Value , "', '")" + ') OR"
    + "         (:list = '_N/A_' and :username is null and :LPNList = '_N/A_')"
    + "        )"
    + "    order by date_updated desc"
    

    在这种情况下,您需要为列表提供默认的空值。我在示例中使用了“N/A”。

    【讨论】:

      猜你喜欢
      • 2014-09-17
      • 2018-08-07
      • 2014-03-25
      • 2014-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多