Skip site navigation (1) Skip section navigation (2)

Re: plpgsql: Is ELSE IF supported or not?

From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: "Marko Kreen" <markokr(at)gmail(dot)com>
Cc: "Postgres Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: plpgsql: Is ELSE IF supported or not?
Date: 2008-06-26 11:32:05
Message-ID: 162867790806260432o74515e8fwfc8958adccfce6e2@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
2008/6/26 Marko Kreen <markokr(at)gmail(dot)com>:
> On 6/26/08, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
>>  2008/6/26 Marko Kreen <markokr(at)gmail(dot)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.
>

this is same in all procedural languages

Pavel

> --
> marko
>

In response to

Responses

pgsql-hackers by date

Next:From: Dimitri FontaineDate: 2008-06-26 11:33:37
Subject: Re: Creating a VIEW with a POINT column
Previous:From: Marko KreenDate: 2008-06-26 11:29:21
Subject: Re: plpgsql: Is ELSE IF supported or not?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group