title: PostgreSQL: control reached end of function without RETURN
body: <p>I'm trying to create a function which returns either X rows or 0 rows.</p>
  
  <p>This is my code:</p>
  
  <pre><code>    ...
      IF var != '' THEN
          RETURN var;
      ELSE
          RETURN NULL;
      END IF;
  END;
  $$
  LANGUAGE 'plpgsql';
  </code></pre>
  
  <p>If I do:</p>
  
  <pre><code>    ...
      IF var != '' THEN
          RETURN var;
      ELSE
          RETURN;
      END IF;
  END;
  $$
  LANGUAGE 'plpgsql';
  </code></pre>
  
  <p>I get the error:</p>
  
  <pre><code>ERROR:  missing expression at or near ";"
  LINE 19: RETURN;
  </code></pre>