title: PL/pgSQL control structures for lists / arrays
body: <p>Is it possible to use something like this in Postgres? This is the example from PL/SQL what I want to do:</p>
  
  <pre><code>PROCEDURE CREATE_PAYMENT(P_AMOUNT IN NUMBER,
                           P_INVOICE_LIST IN SIMPLEARRAYTYPE, 
                           P_AMOUNT_LIST IN NUMBER_TABLE -- pass list of amounts
                              .
                              .
                              .)
  
  s_chk_amnt              NUMBER;
  
  invoice_list SIMPLEARRAYTYPE;
  amount_list NUMBER_TABLE;
  
  BEGIN
        -- check if amount list is null or contains zeros
      IF p_amount_list IS NOT NULL AND p_amount_list.COUNT &lt;&gt; 0 THEN
        FOR r IN p_amount_list.FIRST..p_amount_list.LAST
        LOOP
          s_chk_amnt := s_chk_amnt + p_amount_list(r);
        END LOOP;
      END IF;
  </code></pre>
  
  <p>Can I declare a list of characters and list of numbers as function input parameters?<br>
  I have found some examples with <code>FOREACH element</code> but I don't know how to grab a certain element from number list like in Oracle with <code>p_amount_list(r)</code>.</p>