Re: pl/pgsql oddity

Поиск
Список
Период
Сортировка
От Tomasz Myrta
Тема Re: pl/pgsql oddity
Дата
Msg-id cprkv3$290k$1@news.hub.org
обсуждение исходный текст
Ответ на pl/pgsql oddity  ("Joolz" <joolz@arbodienst-limburg.nl>)
Ответы Re: pl/pgsql oddity
Список pgsql-general
> When writing some serverside code I ran into an oddity that I
> managed to boil down to this:
>
> -------------------------------------------------------
> create or replace function fubar() returns varchar as '
> declare
>   l integer;
> begin
>   l = 38;
>   if l < 38 then
>     return ''< 38'';
>   elseif l >= 38 then
>     return ''>= 38'';
>   else
>     return ''this is not possible'';
>   end if;
> end;'
> language 'plpgsql';
> -------------------------------------------------------
>
> But I can't understand or solve it. The function always returns
> 'this is not possible'. Can someone tell me what I'm overlooking?
> Thanks!

Documentation says you should use "elsif" rather than "elseif". In your
case everything between "return <38" and "else" is discarded as
unreachable code. The same sense will have function below:

create or replace function fubar() returns varchar as '
declare
   l integer;
begin
   l = 38;
   if l < 38 then
     return ''< 38'';
   bleblbebleblebe sfdsdf;
   nothing special;
   else
     return ''this is not possible'';
   end if;
end;'
language 'plpgsql';
select fubar();

Regards,
Tomasz Myrta

В списке pgsql-general по дате отправления:

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: pl/pgsql oddity
Следующее
От: "Joolz"
Дата:
Сообщение: Re: pl/pgsql oddity