title: ORACLE PL/SQL: Functions and Optional Parameters, How?
body: <p>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.</p>
  
  <p>The standard I've been dealing with at my job is this:</p>
  
  <pre><code>FUNCTION get_records (
    i_code                                 IN records.code%type := NULL,
    i_type                                 IN records.type%type := NULL
  ) RETURN results
  </code></pre>
  
  <p>The problem is that I want to return records that have a type of NULL as well, and using:</p>
  
  <pre><code>WHERE type = nvl(i_type, type)
  </code></pre>
  
  <p>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.</p>