Oracle报错误:subquery not allowed in this context 解决方法

淩亂°似流年 2022-04-13 07:51 275阅读 0赞

由于开始编译时候,一直是报编译错误,同时,显示错误是在Oracle中,查询if里面嵌套 in一直显示不允许子查询在里面。

原因:Oracle:IF…IN (SELECT … FROM …) 之子查询不被允许

上代码:

  1. if l_chanl_code in (select REF_CDE from IV_WMS_AUTO_PACK_CONF where REF_TYPE = 'CHANL_CODE' and AUTO_PACK_IND = 'N') then
  2. return 'N';
  3. end if;

这里一直报错。无法编译,那么更改一下即可成功解决。

解决方法:换一种写法。这只是其中的一种写法解决方法,个人还是很嫌弃用in的,因为实在太太太慢了查询。

上代码:

  1. select third_party_cde into l_chanl_code
  2. from es_order_line where order_key = v_order_id and rownum = 1 and third_party_cde in(
  3. select REF_CDE from IV_WMS_AUTO_PACK_CONF where REF_TYPE = 'CHANL_CODE' and AUTO_PACK_IND = 'N'
  4. ) ;
  5. if l_chanl_code is not null then
  6. return 'N';
  7. -- if l_chanl_code in (select REF_CDE from IV_WMS_AUTO_PACK_CONF where REF_TYPE = 'CHANL_CODE' and AUTO_PACK_IND = 'N') then
  8. end if;

发表评论

表情:
评论列表 (有 0 条评论,275人围观)

还没有评论,来说两句吧...

相关阅读