Hi Experts,
I have a question and I don't know if this is possible or not , I am trying to use the CASE statement in WHERE clause to create the SQL
I have an input parameter p_org , If the value of
p_org is 'ABC' , then org_id in (123)
p_org is 'DEF' , then org_id in (456)
p_org is 'GHI' , then org_id in (789)
IF p_org value is ALL , then the query should run for all the three org_id in (123,456,789)
-- i mean something like this but i am unable to figure out how
select * from all_org_tbl
where 1=1
and (
case when
p_org = 'ALL' THEN org_id in in (123,456,789)
when
p_org = 'ABC' THEN org_id in (123)
when
p_org = 'DEF' THEN org_id in (456)
WHEN
p_org = 'GHI' THEN org_id in (789)
END
)
is it possible to achieve this with CASE statement, any help is much appreciated.