I am trying to create a report that allows the users filter out the products that they want to see by adding a parameter for the Product_No in my Oracle PL/SQL. I am using SQL Server Reporting Services that is connected with the Oracle database to my report.
My challenge is that if a user does not enter any Product_No, then my report should return all the products.
While the Product_No has already in my SELECT clause, I felt like adding some condition in the WHERE clause should work.
But something went wrong with my code, and it returns NULL if I do not enter the Product_No (if I enter a Product_No, then it works):
select Product_No, Product_Name
from Product_Table
where (:Product_No is null) OR
((:Product_No is not null) AND Product_No IN (:Product_No))
I simplified my code to make sure I am making sense. Could anyone give me some advice? Appreciated it.