title: Postgres sql ERROR: query has no destination for result datal
body: <pre><code>CREATE OR REPLACE FUNCTION master.test2(tehsil text, district text, state text, flag text)
    RETURNS setof master.population AS
  $BODY$
  BEGIN
  
  
    IF flag='A' THEN
      select Count(*) from master.population where income in('1','2')and statecode=state;
    ELSIF flag='B' THEN
   select Count(*) from master.population where income in('1','2') and statecode=state and districtcode=district ;
     ELSIF flag='C' THEN
    select Count(*) from master.population where income in('1','2') and statecode=state and districtcode=district and tehsilcode=tehsil;
  
  
  ELSE
       select Count(*) from master.population where income in('1','2'); 
  END IF;
  
  END;
  $BODY$
    LANGUAGE plpgsql
  </code></pre>
  
  <p>Throwing an error: </p>
  
  <pre><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 master.test2(text,text,text,text) line 6 at SQL statement
  </code></pre>