Denis,
There is no ELSEIF in PL/pgSQL. You have to use nested IF ... THEN ... ELSE statements instead.
-Josh