Plsql where子句中的CASE结构

Plsql where子句中的CASE结构,plsql,oracle11g,Plsql,Oracle11g,当函数中包装的条件得到满足时,我需要在select查询中包含一个筛选条件。 如果不满足条件,则不应应用过滤条件 代码: select col_a,col_b,cancel_Date from tab_a where col_c = <<some_condition>> and (case when oracle_function() = 'YES' then 'tab_a.cancel_date is null' else null ) 从选项

当函数中包装的条件得到满足时,我需要在select查询中包含一个筛选条件。 如果不满足条件,则不应应用过滤条件

代码:

select col_a,col_b,cancel_Date from tab_a 
where col_c = <<some_condition>>  
and (case when oracle_function() = 'YES' then 'tab_a.cancel_date is null'
      else null
    )
从选项卡a中选择列a、列b、取消日期
其中col_c=
和(当oracle_function()为“是”时,则“tab_a.cancel_date为空”
否则无效
)
如果我这样写,它就会抛出“无效关系运算符”错误。 意识到这种情况应该解决为右侧的值,我尝试添加类似这样的内容,当条件满足时,这些内容不会给我预期的结果:

select col_a,col_b,cancel_Date from tab_a 
where col_c = <<some_condition>>  
and (case when oracle_function() = 'YES' then 'tab_a.cancel_date is null'
       else '1'
      ) = '1'
从选项卡a中选择列a、列b、取消日期
其中col_c=
和(当oracle_function()为“是”时,则“tab_a.cancel_date为空”
其他“1”
) = '1'
我的预期输出应该是:

如果oracle_function()=是,则我的查询应有效地解析为:

select col_a,col_b,cancel_Date from tab_a 
where col_c = <<some_condition>> and tab_a.cancel_date is null;
从选项卡a中选择列a、列b、取消日期
其中col_c=和tab_a.cancel_date为空;
其他:

从选项卡a中选择列a、列b、取消日期
其中col_c=;

有什么想法吗?

此查询要求函数返回除
'YES'
以外的值,或者日期为空,而不是
case
语句。。。这应该与原始查询类似:

select col_a,col_b,cancel_Date 
from tab_a 
where col_c = <<some_condition>>  
and (oracle_function() <> 'YES' OR tab_a.cancel_date is null)
选择列a、列b、取消日期
来自tab_a
其中col_c=
和(oracle函数()是或制表符a.cancel日期为空)
select col_a,col_b,cancel_Date 
from tab_a 
where col_c = <<some_condition>>  
and (oracle_function() <> 'YES' OR tab_a.cancel_date is null)