title: pl/sql function return multiple columns
body: <p>For example I have a query</p>
  
  <pre><code>select (select 1 from dual) res1
         , (select 2 from dual) res2
         , (select 3 from dual) res3 
  from dual;
  </code></pre>
  
  <p>Result: </p>
  
  <pre><code>res1 res2 res3
  ---- ---- ----
     1    2    3
  </code></pre>
  
  <p>I want to create function with loop from 1 to 3 which will return me same result, 3 columns in 1 row</p>
  
  <pre><code> FOR i IN 1..3 LOOP
  
   END LOOP;
  </code></pre>
  
  <p>What should be in function body to achieve goal?
  I know I can use PIVOT to get this result in select query, but parameter of function is dynamic (numberFrom(1) and numberTo(3)), because of it I need loop</p>
  
  <p>Pseudocode:
  Inside loop I have select query, which uses parameters in loop. And result of select should be a new column in final result</p>
  
  <pre><code>FOR i IN 1..3 LOOP
     select i from dual;
  END Loop;
  </code></pre>
  
  <p>I want this:</p>
  
  <p><a href="https://i.stack.imgur.com/XfY9s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XfY9s.png" alt="enter image description here"></a></p>
  
  <p>Not this:</p>
  
  <p><a href="https://i.stack.imgur.com/QDp0f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QDp0f.png" alt="enter image description here"></a></p>
  
  <p>I can pass any integers as parameters. So if I pass 3 and 8 I should qet 3,4,5,6,7,8</p>