Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Parameter passing in query

Hi,
I have an employee table with CNIC# column. if pass dummy parameter in query as 'YES', query find those records having cnic# (cnic# is not null), and if parameter pass with 'NO' then query should find those records that have no cnic# (cnic# is null). if don't pass any parameter then all records should be viewed .
I tried with decode function but I think it don't support the "not null". such as
select emp_id,emp_name,emp_cnic
from employee_view a
where emp_cnic =decode(:p_cnic,'YES',emp_cnis is not null,'NO',emp_cnic is null,emp_cnic)
image.pngOracle 11gR1
Many thanks for the provision of any opinion
Regards.

This post has been answered by cormaco on Aug 23 2021
Jump to Answer
Comments
Post Details
Added on Aug 23 2021
10 comments
326 views