Re: plpgsql: Is ELSE IF supported or not? - Mailing list pgsql-hackers

From Marko Kreen
Subject Re: plpgsql: Is ELSE IF supported or not?
Date
Msg-id e51f66da0806260429x2274c036s3dfe0863e7f71bee@mail.gmail.com
Whole thread Raw
In response to Re: plpgsql: Is ELSE IF supported or not?  ("Pavel Stehule" <pavel.stehule@gmail.com>)
Responses Re: plpgsql: Is ELSE IF supported or not?  ("Pavel Stehule" <pavel.stehule@gmail.com>)
List pgsql-hackers
On 6/26/08, Pavel Stehule <pavel.stehule@gmail.com> wrote:
>  2008/6/26 Marko Kreen <markokr@gmail.com>:
> > Docs seems to say it is, but following function fails to compile:
>  >
>  > create function err_else() returns void as $$
>  > begin
>  >    if 1 = 1 then
>  >    else if 1 = 2 then
>  >    end if;
>  > end;
>  > $$ language plpgsql;
>  >
>  > ERROR:  syntax error at or near ";"
>  > LINE 6: end;
>
> use elseif or elsif :)

Yeah, I know.  Just the docs say this is one "form" of the IF statement:
 IF ... THEN ... ELSE IF

Although now that i read it more, the actual "form" is:
 ELSE    IF THEN    END IF END IF;

That is - the ELSE starts new block unconditionally and ignores any IF
that follows.  Later the IF can be part of new block as usual.  Huh.

This is confusing.  I suggest removing the "ELSE IF" as one of the "forms"
because it is not.

-- 
marko


pgsql-hackers by date:

Previous
From: "Pavel Stehule"
Date:
Subject: Re: plpgsql: Is ELSE IF supported or not?
Next
From: "Pavel Stehule"
Date:
Subject: Re: plpgsql: Is ELSE IF supported or not?