I have a function with parameters. If I pass null as the parameter in a where clause it brings back all results eg
RETURNS TABLE (CUSTOMER_CODE VARCHAR, CUSTOMERNAME VARCHAR)
LANGUAGE SQL
AS '
SELECT CUSTOMER_CODE, CUSTOMERNAME FROM DIM_CUSTOMER
WHERE CUSTCODE IS NULL OR CUSTOMER_CODE = CUSTCODE
'
I would like to change the SQL to if the parameter CUSTCODE = 'ALL' then pass NULL value and bring back all results else CUSTOMER_CODE = CUSTCODE
Thank you in advance!
Leon