title: Postgres Stored Procedures: how to return both multiple records with an out parameter?
body: <p>I have a function in Postgres 9.4 similar to this one:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION myF(
    INOUT _p1 character varying,
    IN _p2 integer,
    OUT _p3 boolean) 
  RETURNS setof retVal AS 
  $BODY$
    _p3 := '0';
    RETURN query SELECT 1 AS col1, 'test' as col2;
  END;$BODY$
  LANGUAGE plpgsql VOLATILE NOT LEAKPROOF
  COST 100;
  </code></pre>
  
  <p>Having type retVal defined as well:</p>
  
  <pre><code>create type retVal as (col1 int, col2 character varying);
  </code></pre>
  
  <p>The body of the function is far more complex (and I need plpgsql for this purpose), and I have to invoke it from a Java program thru a </p>
  
  <pre><code>CallableStatement.executeQuery()
  </code></pre>
  
  <p>My questions are:
  1) what should I put as RETURNS value in the function?
  2) Is it correct to return the result via RETURN query syntax?</p>
  
  <p>Thank you very much!</p>