title: Syntax error at or near ;
body: <p>I have many trigger functions, and for some there is a strange error: "<code>Syntax error at or near ;</code>" Here is my code:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION zajisti_vyplnenost() RETURNS trigger AS $$
  BEGIN
    IF NEW.typ_vztahu != 1 THEN
      RETURN NEW;
    END IF;
  
    IF NEW.nad.typ_sj = 1 THEN
      IF NEW.nad.vrstva.vypln = true THEN
      ELSE
        RAISE EXCEPTION 'Totožné stratigrafické jednotky musejí být stejného typu!';
    END IF;
  
    RETURN NEW;
  END;
  $$ LANGUAGE plpgsql;
  
  CREATE TRIGGER zajisti_vyplnenost
  BEFORE INSERT OR UPDATE ON s_vztah
  FOR EACH ROW
    EXECUTE PROCEDURE zajisti_vyplnenost();
  </code></pre>
  
  <p>According to the debugger, the error should be on line 14 (with <code>END;</code>). I tried to find something which might cause the problem, but this function looks like the others which don't trigger any errors. I looked on some documentation for function and END syntax in plpgsql, but with no joy, and semicolon makes the error quite Google unfriendly.</p>
  
  <p>So which part of my syntax is wrong, and how to correct it?</p>