I'm looking for the optimal way to create a function that can accept no parameters and return all results, but also accepts parameters and return those results.
The standard I've been dealing with at my job is this:
FUNCTION get_records (
i_code IN records.code%type := NULL,
i_type IN records.type%type := NULL
) RETURN results
The problem is that I want to return records that have a type of NULL as well, and using:
WHERE type = nvl(i_type, type)
It only returns records with actual types and not the null records.. for obvious reasons. I was just wondering if there is a standard way of doing this that could be implemented across all functions we use. Coincidentally, if I provide a parameter... I don't want the NULL values of that field.