Parameter list of values with null check
Hi,
We are trying to find a solution to the following problem in a datamodel. We have a user input parameter called P_ LIST, which contains a comma-separated list of values, for example:
COPENHAGEN,STOCKHOLM,AMSTERDAM
We have a table which contains values as such:
City | Population |
---|---|
COPENHAGEN | 10 |
STOCKHOLM | 20 |
AMSTERDAM | 30 |
The user can input one of the following variations into the parameter field:
COPENHAGEN
COPENHAGEN,STOCKHOLM
COPENHAGEN,STOCKHOLM,AMSTERDAM
STOCKHOLM,AMSTERDAM
AMSTERDAM,COPENHAGEN
NULL (i.e. no input, should show all cities)
The SQL query is:
with cities as (SELECT 'COPENHAGEN' city,10 population from dual
UNION
SELECT 'STOCKHOLM' city, 20 population from dual