title: Oracle Pipelined function
body: <p>I'm trying to create a function which returns an object that can be used in the FROM Clause. According to research on the oracle documentation I've found that a PIPELINED function is what I need.</p>
  
  <p>I have this code:</p>
  
  <pre><code>CREATE TYPE type_struct AS OBJECT
  (
      i NUMBER
  );
  
  CREATE TYPE tp_struct AS TABLE OF type_struct;
  
  CREATE OR REPLACE FUNCTION gen_nums (na NUMBER, nb NUMBER)
  RETURN tp_struct PIPELINED
  IS
      rec type_struct;
      counter NUMBER;
  BEGIN
      counter := na;
  
      WHILE (counter &lt;= nb)
      LOOP
          SELECT counter
          INTO rec
          FROM dual;
  
          counter := counter + 1;
  
          PIPE ROW (rec);
      END LOOP;
  
      RETURN;
  END gen_nums;
  /
  </code></pre>
  
  <p>The intended result is a table with records from 'na' to 'nb', both inclusive.</p>
  
  <p>However I get this error when compiling the function:</p>
  
  <blockquote>
    <p>ORA 00932 inconsistent datatypes expected udt got number</p>
  </blockquote>