I think you're short an END IF. Last I checked, plpgsql didn't have an "else if" construct, so it wants an END IF to go with each IF. regards, tom lane
pgsql-sql by date:
Соглашаюсь с условиями обработки персональных данных