oracle - Using a parameter to filter out multiple values in sql -
in query (note i'm not using procedure) need use boolean parameter define whether filter out records or not.
my parameter's name "wo" (= without). - if user chooses &wo = 'true'
want records filtered out.
my approach use 'case when' in clause following:
select * tbl1 case when &wo = 'true' tbl1.field1 not in ('ab','cd','ef') end
i know syntax or whole approach incorrect.
you can't use case
that; result of case
needs compared something. this:
select * tbl1 nvl('&wo', 'false') != 'true' or tbl1.field1 not in ('ab','cd','ef')
if first part of or
equates false - is, &wo
null or not true
- second part not evaluated.
Comments
Post a Comment