Some One
Some One

Reputation: 31

How to output 'is null' in a where clause in a case when statement?

The query checks the value of a parameter foo which is passed by a dropdown inside a program. If that paramater contains a certain value, an attribute should only contain null values. Can I manage that without pl/SQL?

select * from table t
where case when $foo$ = 'yes' then t.something is null end

Upvotes: 0

Views: 33

Answers (2)

Barbaros Özhan
Barbaros Özhan

Reputation: 65408

Just use nvl function :

select * 
  from mytable t
 where nvl($foo$,'yes') = 'yes';

Upvotes: 0

Andrew
Andrew

Reputation: 27314

Do you mean this logic?

select something 
from table t
where ($foo$ = 'yes' and t.something is null) or ($foo != 'yes')

Upvotes: 1

Related Questions