1
Hello. I have an application for assembly of queries, in which I pass the parameters in the clause "Where". Only I came across a situation where I need to use CASE and in the THEN clause a range of values (to return in an IN). The idea goes something like this:
select [...]
from table
where campo in
case
when <condicao1> then 'Valor1'
when <condicao2> then 'Valor1', 'Valor2'
else 'Valor3' end
The problem is precisely in condica2, when I provide more than one value, the case syntax does not accept 'Valor1', 'Valor2'. Does anyone have an idea if there’s a way to do it?
Try 1 return between () then (value1) 2 the good is old "if" Where ( (<cond1> and field = 'value1') or (<cond2> and field in ('value1','value2') )
– Motta
I tried this but Oracle does not accept the syntax select * from user_objects Where object_type in (CASE WHEN 1=1 THEN ('TABLE','INDEX') ELSE ('FUNCTION') END) ORA-00907: Missing right parenthesis
– Motta