title: Running a SELECT in a PL/pgSQL block
body: <p>I am newbie to PostgreSQL and I have to use inline queries in SSRS report to fetch data from PostgreSQL DB.</p>
  
  <p>The scenario is: based on selected value of the report parameter I need to get output from different tables. Please see the below sample inline query.</p>
  
  <pre><code>    DO
      $do$
  
      BEGIN
      IF ($1 = 'Monthly') THEN
  
      SELECT *
      FROM table1;
  
      ELSE 
  
      SELECT *
      FROM table2;
  
      END IF;
  
      END
      $do$
  </code></pre>
  
  <p>The above query is giving error,</p>
  
  <blockquote>
    <p><strong>ERROR</strong>: query has no destination for result data
    SQL state: 42601
    Hint: If you want to discard the results of a SELECT, use PERFORM instead.
    Context: PL/pgSQL function inline_code_block line 6 at SQL statement</p>
  </blockquote>
  
  <p>Please note that I cannot use Stored procedures or Functions to retrieve the required data and I have to use inline queries only.</p>
  
  <p>Can some one let me know of how to solve above error?</p>