hi, I need help to write a query (no pl/sql) with the conditional where clause.
The condition is driven by the content of the MY_VAR variable.
In case MY_VAR contains a value other than 'ALL'
The query should extract from a table tbl1 all the records in which the value of the X field is in a list extracted with a subquery
If the content of the MY_VAR is equal to 'ALL' all the records should be extracted (no where condition)
something like: (bad syntax)
select *
from tbl1 t1
CASE
when my_var <> 'ALL' then where t1.x in (select t2.x fro tbl2 t2)
else ''
END
Thanks in advance
regards
saverio