title: How to define a pl sql function with dynamic return types in Oracle?
body: <p>I have a set of tables with different data type for the columns and I need to consolidate a way for retrieving data. I thought using a function would be a good idea, but I don't know how to define one function having different return types.</p>
  
  <p>For example, how to define this function to be able to use different definitions for tabletype.</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION retrieve_info(field_id in integer)
  RETURN pintegertypetable -- &lt;-- how to change this to return a more generic record built dynamically in the code below?
  AS
    r pintegertypetable := pintegertypetable ();
  BEGIN
    r.extend;
    r(i) := pintegertypetable (someinteger);
    return r;
  END;
  </code></pre>
  
  <p>Is that possible?. Is there a better way to handle this problem: different columns stored originally in a lot of legacy tables, and given that every column has different data types, in which way we can retrieve the most recent information conserving the original data types without hardcoding views neither storing everything in varchar2 and casting again in client code?</p>