I am looking for the best way to create a function that cannot accept any parameters and return all results, but also accepts parameters and returns these results.
The standard that I had at my work 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 are of type NULL and using:
WHERE type = nvl(i_type, type)
It only returns records with actual types and not with null records .. for obvious reasons. I am just wondering if there is a standard way to do this that can be implemented in all the functions that we use. Coincidentally, if I provide a parameter ... I do not want the NULL value of this field.
source
share