title: SELECT usage with the new CREATE PROCEDURE method
body: <p>I'm trying to store a simple <code>SELECT</code> query with the new <code>CREATE PROCEDURE</code> method in PostgreSQL 11. My idea is to store the queries in the DB, because I can have a much simple code in my API server and maybe I don't need to develop a query builder if I can use if/else in an sql function with enforced type safety. I have this minimal example:</p>
  
  <p>First I tried this plpgsql function:</p>
  
  <pre><code>CREATE OR REPLACE PROCEDURE test_proc() AS $$
      BEGIN
          SELECT * FROM my_db
          LIMIT 1;
      END;
  $$ LANGUAGE plpgsql;
  
  CALL test_proc();
  </code></pre>
  
  <p>However throws this error:</p>
  
  <p><code>ERROR: query has no destination for result data
  HINT: If you want to discard the results of a SELECT, use PERFORM instead.
  CONTEXT: PL/pgSQL function test_proc() line 3 at SQL statement SQL state: 42601</code></p>
  
  <p>If I trying to use <code>RETURN QUERY</code>:</p>
  
  <pre><code>CREATE OR REPLACE PROCEDURE test_proc() AS $$
      BEGIN
          RETURN QUERY;
          SELECT * FROM my_db
          LIMIT 1;
      END;
  $$ LANGUAGE plpgsql;
  </code></pre>
  
  <p>I'm getting this error:</p>
  
  <p><code>ERROR: cannot use RETURN QUERY in a non-SETOF function
  LINE 17: RETURN QUERY; ^
  SQL state: 42804
  Character: 310</code></p>
  
  <p>I'm also getting error when I try to use <code>RETURNS void AS $$</code> or <code>RETURNS table(...) AS $$</code>. Seems like <code>RETURNS</code> not supported in <code>CREATE PROCEDURE</code>? So, is it possible to return a table with the new stored procedure method? Or if it's not, maybe JSON?</p>