title: Function Using Generic Type
body: <p>I'd like to make a function that replicates the effects of something like nvl2. To do this I created a function that looks like </p>
  
  <pre><code>  function nvl2(in_checkNull anydata, not_null_return_value anydata, null_return_value anydata) return anydata is
    begin
      if in_checkNull is null then
        return null_return_value;
      else
        return not_null_return_value;
      end if;
    end;
  </code></pre>
  
  <p>The problem with this is that I want to call the function like</p>
  
  <pre><code>nvl2(my_type, my_type.my_number, 0);
  </code></pre>
  
  <p>But it's not working. I looked into the problem and it seems I need to cast everything to the anydata type but this defeats the point since now I may as well just write out the entire if statement. Is there anyway to make this function work without having to go through painful and verbose casts and setup?</p>