title: unexpected end of function definition on PostgreSQL function
body: <p>What is wrong with this function? 
  EDITED>></p>
  
  <pre><code>CREATE OR REPLACE FUNCTION on_ai_myTable() RETURNS TRIGGER AS $$
  
  BEGIN
  SELECT fn_name, count(*) + 1 FROM table_ebscb_spa_log02 WHERE time_type = 'Start' GROUP BY fn_name
  RETURN NEW.fn_name;
  END
  $$
  LANGUAGE plpgsql;
  </code></pre>
  
  <p>Ok I added the ";" but now, when I try to create it, it send me the message  ERROR: syntax error at or near "RETURN"
  LINE 5: RETURN fn_name;</p>
  
  <p>How can I solve it????</p>
  
  <p>Thanks Advanced.</p>