title: plpgsql Error: RETURN cannot have a parameter in function returning void
body: <p>I am trying to extract the count of records corresponding to a specific date and user_ids which do not have corresponding user_ids for the next later date in the database.  This is the way I am trying to accomplish it (using plpgsql but not defining a function:</p>
  
  <pre><code>    DO
      $BODY$
      DECLARE
          a date[]:= array(select distinct start_of_period from monthly_rankings where balance_type=2);
          res int[] = '{}';
      BEGIN
          FOR i IN array_lower(a,1) .. array_upper(a,1)-1
          LOOP
              res:=array_append(res,'SELECT COUNT(user_id) from (select user_id from monthly_rankings where start_of_period=a[i] except select user_id from monthly_rankings where start_of_period=a[i+1]) as b');
                      i:=i+1;
              END LOOP;
              RETURN res;
          $BODY$ language plpgsql
  </code></pre>
  
  <p>I get an Error: could not Retrieve the result : ERROR:  RETURN cannot have a parameter in function returning void
  LINE 11:   RETURN res;
   I am new to this procedural language and cannot spot why the function is returning void. I do assign the values to variables , and I declared empty - not NULL - arrays. Is there a syntax or a more significant reasoning mistake? </p>