title: How to migrate oracle's pipelined function into PostgreSQL
body: <p>As I am newbie to plpgSQL,</p>
  
  <p>I stuck while migrating a Oracle query into PostgreSQL.</p>
  
  <p>Oracle query:</p>
  
  <pre><code>create or replace FUNCTION employee_all_case(
     p_ugr_id IN integer,
     p_case_type_id IN integer
  )
  RETURN number_tab_t PIPELINED
  --       LANGUAGE 'plpgsql'
  --     COST 100
  --     VOLATILE 
  --     AS $$
  --     DECLARE
  is
    l_user_id        NUMBER;
    l_account_id     NUMBER;
  BEGIN
    l_user_id      := p_ugr_id;
    l_account_id   := p_case_type_id;
    FOR cases IN
      (SELECT ccase.case_id, ccase.employee_id
       FROM ct_case ccase
         INNER JOIN ct_case_type ctype
           ON (ccase.case_type_id=ctype.case_type_id)
       WHERE ccase.employee_id = l_user_id)
    LOOP
      IF cases.employee_id IS NOT NULL THEN
        PIPE ROW (cases.case_id);
      END IF;
    END LOOP;
    RETURN;
  END;
  --$$
  </code></pre>
  
  <p>When I execute this function then I get the following result</p>
  
  <pre><code>select * from table(select employee_all_case(14533,1190) from dual)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/fAgsC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fAgsC.png" alt="enter image description here"></a></p>
  
  <p>My question here is: I really do not understand the pipelined function and how can I obtain the same result in PostgreSQL as Oracle query ?</p>
  
  <p>Please help.</p>