title: PL/SQL: Cannot cast table%ROWTYPE to user-defined TYPE TABLE. But no error given
body: <p>I have a <strong>Package</strong> with a <strong>user-type <code>RECORD</code></strong> AND a <strong>user-type <code>TABLE</code></strong> of the first type:</p>
  
  <pre><code>TYPE ObjData IS RECORD (
      Test date NOT NULL := DATE '0001-01-01',
      Val decimal
  );
  TYPE ObjDataCollection IS TABLE
      OF ObjData;
  </code></pre>
  
  <p>I need to call a <code>PROCEDURE</code> from the Package passing as param a <code>ObjDataCollection</code> object, fetched from a DBTable:</p>
  
  <pre><code>SELECT LogDate, TypeVal FROM UserLogs
  </code></pre>
  
  <p>When I call the query, it returns dozens of records, but nothing is returned by this function I tried:</p>
  
  <pre><code>CREATE FUNCTION TestData RETURN MyPackage.ObjDataCollection AS
    res MyPackage.ObjDataCollection;
  BEGIN
    SELECT LogDate, TypeVal
      BULK COLLECT INTO res
      FROM UserLogs
      ORDER BY LogDate;
    RETURN res;
  END TestData;
  </code></pre>
  
  <p>This is Running window Log:</p>
  
  <pre><code>Connecting to the database MYDB.
  Process exited.
  Disconnecting from the database MYDB.
  </code></pre>
  
  <p>And this is the Output Variables window (it's empty):
  <img src="https://i.stack.imgur.com/ihn2x.png" alt="Screenshot"></p>