如果我的字段为空,那么我需要条件
select * from data where :P2_EMPLOYEE is null then MANAGER = 'Alex'
我认为您需要coalesce()
:
select *
from data
where MANAGER = coalesce(:P2_EMPLOYEE,'Alex')
,
其他一些选项(除了您已经看到的选项之外):
where manager = case when :P2_EMPLOYEE is null then 'Alex'
else :P2_EMPLOYEE
end;
where manager = decode(:P2_EMPLOYEE,null,'Alex',:P2_EMPLOYEE)
where manager = nvl(:P2_EMPLOYEE,'Alex')