Re: pl/pgsql trigger: syntax error at or near "ELSEIF"

From: Roman Neuhauser <neuhauser(at)chello(dot)cz>
To: Alban Hertroys <alban(at)magproductions(dot)nl>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: pl/pgsql trigger: syntax error at or near "ELSEIF"
Date: 2005-01-14 16:24:11
Message-ID: 20050114162411.GB11065@isis.wad.cz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

# alban(at)magproductions(dot)nl / 2005-01-14 13:27:24 +0100:
> Roman Neuhauser wrote:
> >Hello, what is the parser trying to tell me? (7.4.2 if it matters)
> >test'# ELSEIF TG_OP = ''DELETE'' THEN
>
> You typed ELSEIF, the parser doesn't know what that means (It's either
> ELSIF or ELSE IF).

Thanks to everyone who pointed this out for me.

> >On a related note: if I replace NEW with OLD in the second UPDATE (in the
> >ELSEIF branch), I get:
> >What's wrong with that?
>
> OLD doesn't exist in INSERT triggers, only in UPDATE and DELETE
> triggers. A record in an INSERT trigger is by definition a new record,
> an old record wouldn't make sense.
>
> IMHO, it would be better to write two or three different triggers (one
> on INSERT, the other on DELETE, and maybe a third on UPDATE) than
> writing a single and trying to figure out which of those three it was in
> the trigger.

Thanks, going that route indeed solved the problem.

--
If you cc me or remove the list(s) completely I'll most likely ignore
your message. see http://www.eyrie.org./~eagle/faqs/questions.html

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John Sidney-Woollett 2005-01-14 16:30:59 C locale + unicode
Previous Message Eric Dorland 2005-01-14 16:16:16 Problem Dropping a Database with users connected to it