I tried using case statement in the where clause, which needs to filter my where condition based on the parameter value passed to my procedure, but it didn't worked
where case when p_parameter ='Y' then 'Y' else ('Y','N') END in Hidden_flag_column
Try
where
case when p_parameter ='Y'
then case when Hidden_flag_column = 'Y' then 1 else 0 end
else case when Hidden_flag_column in ('Y','N') then 1 else 0 end
END = 1
Example with p_parameter = 'Y' as well as 'N' and Hidden_flag_column = 'N'.
select * from dual
where
case when 'N' ='Y'
then case when 'N' = 'Y' then 1 else 0 end
else case when 'N' in ('Y','N') then 1 else 0 end
END = 1
gives 1 row while
select * from dual
where
case when 'Y' ='Y'
then case when 'N' = 'Y' then 1 else 0 end
else case when 'N' in ('Y','N') then 1 else 0 end
END = 1
gives 0 rows.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.