ORA-00907: 缺少右括号。我正在传递一个变量 '&Coordinator_Id&'

ORA-00907: missing right parenthesis. I am passing a Variable '&Coordinator_Id&'

ORA-00907: missing right parenthesis

我正在尝试 运行 代码,但一直出现正确的括号错误 我检查了整个代码。有人能看出我失败的原因吗?

select * from CUSTOMER_ORDER_JOIN
 where 
CASE  WHEN CF$_ZCOORDINATORID is not null  THEN 
  ((TRIM(upper('&Coordinator_ID&')) LIKE upper((select CUSTOMER_ORDER_API.GET_AUTHORIZE_CODE(ORDER_NO) from dual) ))
    and (OBJSTATE = (select CUSTOMER_ORDER_LINE_API.FINITE_STATE_ENCODE__('Partially Delivered') from dual)
    or OBJSTATE = (select CUSTOMER_ORDER_LINE_API.FINITE_STATE_ENCODE__('Picked') from dual)
    or OBJSTATE = (select CUSTOMER_ORDER_LINE_API.FINITE_STATE_ENCODE__('Released') from dual)
    or OBJSTATE = (select CUSTOMER_ORDER_LINE_API.FINITE_STATE_ENCODE__('Reserved') from dual)))  
    
  ELSE ((TRIM(upper('&Coordinator_ID&')) LIKE upper((select CUSTOMER_ORDER_API.GET_AUTHORIZE_CODE(ORDER_NO) from dual) ) or
         TRIM(upper('&Coordinator_ID&')) is not null)
          and (OBJSTATE = (select CUSTOMER_ORDER_LINE_API.FINITE_STATE_ENCODE__('Partially Delivered') from dual)
          or OBJSTATE = (select CUSTOMER_ORDER_LINE_API.FINITE_STATE_ENCODE__('Picked') from dual)
          or OBJSTATE = (select CUSTOMER_ORDER_LINE_API.FINITE_STATE_ENCODE__('Released') from dual)
          or OBJSTATE = (select CUSTOMER_ORDER_LINE_API.FINITE_STATE_ENCODE__('Reserved') from dual))) 
  END

如评论中所述,case 表达式计算出一个值,然后您可以使用该值或将其与其他值进行比较。在 where 子句中,仅使用布尔逻辑通常更简单,因此您可以删除 case 表达式;您还可以删除很多针对 dual 的重复和不必要的子查询,以获得类似:

select * from CUSTOMER_ORDER_JOIN
where 
(
  TRIM(upper('&Coordinator_ID&')) LIKE upper(CUSTOMER_ORDER_API.GET_AUTHORIZE_CODE(ORDER_NO))
  or (CF$_ZCOORDINATORID is null and TRIM(upper('&Coordinator_ID&')) is not null)
)
and
(
  OBJSTATE = CUSTOMER_ORDER_LINE_API.FINITE_STATE_ENCODE__('Partially Delivered')
  or OBJSTATE = CUSTOMER_ORDER_LINE_API.FINITE_STATE_ENCODE__('Picked')
  or OBJSTATE = CUSTOMER_ORDER_LINE_API.FINITE_STATE_ENCODE__('Released')
  or OBJSTATE = CUSTOMER_ORDER_LINE_API.FINITE_STATE_ENCODE__('Reserved')
) 

尽管 LIKE 可能应该是 =,而 not null 检查中的 upper() 并没有真正做任何事情 - 无法判断其他人是否是必要的;您可以使用 in() 进行 OBJSTATE 检查。

我相信捕获的逻辑与您问题中的版本相同。