Help required in creating a function that produces output based on the configuration table

Hi All,

I have a requirement to credate a dynamic function which can be used in a stored procedure. Within this procedure, we handle various case conditions for each client, and to retrieve values where the filtering conditions differ, I am considering employing a function within the SELECT query instead of using case statements.

image

Based on the provided context, the function should internally generate a query and generate output according to the configuration.

The function requires only one parameter: the client's name

SELECT
CASE
WHEN client ='ABC' AND location IN ('UK','UN') AND LOCTYPE IN ('D','H') THEN 1
ELSE 0
END
FROM
config;

SELECT
CASE
WHEN client ='XYZ' AND location IN ('IN') AND LOCTYPE = 'D' THEN 1
ELSE 0
END
FROM
config;

Thanks,
Vipin jha