title: RETURN QUERY vs RETURN QUERY EXECUTE
body: <blockquote>
    <p><a href="https://www.postgresql.org/docs/9.1/static/plpgsql-control-structures.html" rel="noreferrer">PostgreSQL 39.6. Control Structures:</a> RETURN QUERY has a variant RETURN QUERY EXECUTE, which specifies the query to be <strong>executed dynamically</strong>. Parameter expressions can be inserted into the computed query string via USING, in just the same way as in the EXECUTE command. </p>
  </blockquote>
  
  <p>But what means <strong>dynamically</strong>?</p>
  
  <p>What is a difference between these two statements (inside function with <code>func_param</code> parameter):</p>
  
  <pre><code>RETURN QUERY SELECT * FROM foo WHERE foo_col = func_param;
  </code></pre>
  
  <p>and </p>
  
  <pre><code>RETURN QUERY EXECUTE 'SELECT * FROM foo WHERE foo_col = $1' USING func_param;
  </code></pre>
  
  <p>?</p>